File tree 2 files changed +50
-1
lines changed
2 files changed +50
-1
lines changed Original file line number Diff line number Diff line change @@ -178,7 +178,7 @@ var workflow = {
178
178
179
179
180
180
return function execute ( done ) {
181
-
181
+ var wfStartTime = new Date ( ) . getTime ( )
182
182
183
183
if ( ! checkCondition ( context ) )
184
184
return done ( )
@@ -266,6 +266,9 @@ var workflow = {
266
266
}
267
267
268
268
debug ( "Finished executing WF %s" , getStepName ( workflowDefinition ) )
269
+ if ( context . $$$stats ) {
270
+ context . $$$stats . push ( getStepName ( workflowDefinition ) + " execution time: " + ( new Date ( ) . getTime ( ) - wfStartTime ) + "ms" )
271
+ }
269
272
var originalDone = context . originalTerminate || done ;
270
273
var donePosition = context . completionStack . indexOf ( originalDone ) ;
271
274
context . completionStack . splice ( donePosition , 1 )
Original file line number Diff line number Diff line change
1
+ var worksmith = require ( '..' )
2
+ var assert = require ( 'assert' )
3
+
4
+ describe ( "workflow status" , function ( ) {
5
+ it ( "should be created" , function ( done ) {
6
+ this . slow ( )
7
+ var wf = worksmith ( [
8
+ {
9
+ name :"t1" ,
10
+ taskName :"t1" ,
11
+ task : function ( def ) {
12
+ return function build ( context ) {
13
+ return function execute ( d ) {
14
+
15
+ //console.log("d1")
16
+ setTimeout ( function ( ) {
17
+ d ( )
18
+ } , 500 )
19
+ }
20
+ }
21
+ }
22
+ } ,
23
+ {
24
+ taskName :"t2" ,
25
+ name : "t2" ,
26
+ task : function ( def ) {
27
+ return function build ( context ) {
28
+ return function execute ( d ) {
29
+ //console.log("d2")
30
+ setTimeout ( function ( ) {
31
+ d ( )
32
+ } , 500 )
33
+ }
34
+ }
35
+ }
36
+ }
37
+
38
+ ] ) ;
39
+ var before = Date . now ( )
40
+ var ctx = { $$$stats : [ ] }
41
+ wf ( ctx , function ( err , result , ctx ) {
42
+ assert ( ctx . $$$stats . join ( "" ) . match ( / t 1 e x e c u t i o n t i m e : [ 0 - 9 ] { 3 } m s t 2 e x e c u t i o n t i m e : [ 0 - 9 ] { 3 } m s s e q u e n c e e x e c u t i o n t i m e : [ 0 - 9 ] { 4 } m s / ) )
43
+ done ( null , result )
44
+ } )
45
+ } )
46
+ } )
You can’t perform that action at this time.
0 commit comments