-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbulk-test.js
51 lines (47 loc) · 1.36 KB
/
bulk-test.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
45
46
47
48
49
50
51
const { buildInstance } = require('./utils/factory');
const {
identification_updateSkills,
runner_setMinSpeed,
runner_setMaxSpeed,
runner_cross
} = require('./helpers')();
const testTimeInSecs = process.argv[2] || 5;
const start = Date.now();
let immedRef;
let i = 0;
let j = 0;
let agent1;
immedRef = setImmediate(function chunk() {
while (i < 10000) {
// const agent1 = buildInstance({ tick_open, tick_close, tick_print }, 'agent-' + j, initState);
const agent1 = buildInstance(
{ identification_updateSkills, runner_setMinSpeed, runner_setMaxSpeed },
'agent-' + j
);
// agent1 = buildInstance({
// identification_updateSkills,
// runner_setMinSpeed,
// runner_setMaxSpeed
// }); // uuid v4 autogen makes it 75% slower, improve it!
// agent1.tick_open(1.23123);
// agent1.tick_close(1.92314);
// agent1.tick_open(523423);
// agent1.tick_close(1.129381);
// agent1.tick_open(1.32367);
i++;
j++;
}
immedRef = setImmediate(chunk);
i = 0;
});
const intrv = 1000;
const intRef = setInterval(() => {
const seconds = (Date.now() - start) / intrv;
// console.log({ seconds, j, 'insts/sec': j / seconds });
if (seconds > testTimeInSecs) {
console.log({ seconds, j, 'insts/sec': j / seconds });
clearInterval(intRef);
clearImmediate(immedRef);
// agent1.tick_print();
}
}, intrv);