-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathbenchmarkpython.js
More file actions
30 lines (27 loc) · 802 Bytes
/
benchmarkpython.js
File metadata and controls
30 lines (27 loc) · 802 Bytes
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
const BenchMark = require('./build/releasejscallpython/BenchMark_proxy');
const b = new BenchMark({}, {},);
console.log('start');
async function bm(block) {
return new Promise((resolve) => {
b.call({
param_buffer: block
}, resolve);
});
}
const L = 200000;
const block_size = 1024;
b.ready(async () => {
console.log('ready');
const block = Buffer.alloc(block_size);
const start = Date.now();
for (let i = 0; i < L; ++ i) {
await bm(block);
}
const end = Date.now();
const cost = end-start;
console.log(`loop times ${L}`);
console.log(`block_size: ${block_size} byte`);
console.log(`cost: ${cost} ms`);
console.log(`band width: ${block_size*L/(cost/1000)} byte/s`);
console.log(`latency: ${cost/L} ms`);
});