-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathtiming.js
44 lines (38 loc) · 1.13 KB
/
timing.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
if (process.argv.length < 4) {
console.error('Github username and password/token required as arguments');
process.exit(1);
}
var $login = process.argv[2];
var $password = process.argv[3];
var exec = require('child_process').exec;
var scripts = [ {name: 'api.js'}, {name:'module.js'}, {name:'node.js'} ];
var i = 0, current = 0;
scripts.forEach(function (script) {
script.exec = function () {
script.start = {
'date': new Date(),
'hrtime': process.hrtime()
};
var child = exec('node ./' + script.name + ' ' + $login + ' ' + $password);
// child.stdout.on('data', console.log);
child.stderr.on('data', console.error);
child.on('close', function () {
script.end = {
'date': new Date() - script.start.date,
'hrtime': process.hrtime(script.start.hrtime)
};
current++;
if (current == scripts.length)
fin();
else
scripts[current].exec();
});
};
if (++i == scripts.length)
scripts[current].exec();
});
function fin() {
scripts.forEach(function (script) {
console.info('(%s) Execution time: %dms', script.name, script.end.date);
});
}