Skip to content

Commit 62c381b

Browse files
committedJul 16, 2015
Improving the average function reusability for stress tests
1 parent d3373e1 commit 62c381b

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed
 

‎stress-test/stress-test.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,28 @@ try {
1111
worksmith.use("lodash", worksmith.createAdapter(require('lodash')))
1212
var workflow = worksmith("./stress-test/stress-workflows/workflow1.js")
1313
console.log('About to execute workflow1')
14-
calculateAverageExecTime(function(average) {
14+
calculateAverageExecTime(workflow, function(average) {
1515
console.log('The average execution time is: ', average, ' ms')
1616
})
1717
} catch(e) {
1818
console.error('There was an error setting up a workflow: ', e)
1919
}
2020

21-
function calculateAverageExecTime(next) {
21+
function calculateAverageExecTime(workflow, next) {
2222
var average = counter = 0
2323
async.whilst(
2424
function () { return counter < SAMPLE_SIZE },
2525
function (cb) {
2626
counter++;
2727
var ctx = {}
2828
workflow(ctx, function(err, results) {
29-
if (err) console.error('There was an error running a workflow: ', err.toString())
29+
if (err) return cb(err)
3030
average += ctx.duration
3131
cb()
3232
})
3333
},
3434
function (err) {
35+
if (err) console.error('There was an error running a workflow: ', err.toString())
3536
next(average / SAMPLE_SIZE)
3637
}
3738
)

0 commit comments

Comments
 (0)
Please sign in to comment.