Skip to content

Commit bbe2421

Browse files
author
gretacb
committed
capture time before any work begins
1 parent d4bd145 commit bbe2421

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

bench/hello_async.bench.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ var path = require('path');
1818
var assert = require('assert')
1919
var d3_queue = require('d3-queue');
2020
var module = require('../lib/index.js');
21-
var queue = d3_queue.queue(argv.concurrency);
21+
var queue = d3_queue.queue();
2222
var runs = 0;
2323

2424
function run(cb) {
@@ -31,12 +31,15 @@ function run(cb) {
3131
});
3232
}
3333

34+
// Start monitoring time before async work begins within the defer iterator below.
35+
// AsyncWorkers will kick off actual work before the defer iterator is finished,
36+
// and we want to make sure we capture the time of the work of that initial cycle.
37+
var time = +(new Date());
38+
3439
for (var i = 0; i < argv.iterations; i++) {
3540
queue.defer(run);
3641
}
3742

38-
var time = +(new Date());
39-
4043
queue.awaitAll(function(error) {
4144
if (error) throw error;
4245
if (runs != argv.iterations) {

bench/hello_object_async.bench.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ var d3_queue = require('d3-queue');
2020
var module = require('../lib/index.js');
2121

2222
var H = new module.HelloObjectAsync('park bench');
23-
var queue = d3_queue.queue(argv.concurrency);
23+
var queue = d3_queue.queue();
2424
var runs = 0;
2525

2626
function run(cb) {
@@ -33,12 +33,15 @@ function run(cb) {
3333
});
3434
}
3535

36+
// Start monitoring time before async work begins within the defer iterator below.
37+
// AsyncWorkers will kick off actual work before the defer iterator is finished,
38+
// and we want to make sure we capture the time of the work of that initial cycle.
39+
var time = +(new Date());
40+
3641
for (var i = 0; i < argv.iterations; i++) {
3742
queue.defer(run);
3843
}
3944

40-
var time = +(new Date());
41-
4245
queue.awaitAll(function(error) {
4346
if (error) throw error;
4447
if (runs != argv.iterations) {

0 commit comments

Comments
 (0)