source: benchmark/ctxswitch/node_cor.js @ 1e110bf

Last change on this file since 1e110bf was 3c64c668, checked in by Peter A. Buhr <pabuhr@…>, 4 years ago

warm JIT for node.js benchmarks

  • Property mode set to 100644
File size: 583 bytes
Line 
1var times = 50000000
2var argc = process.argv.length // node, path
3if ( argc > 3 ) process.exit( 1 )
4if ( argc == 3 ) times = Number( process.argv[2] )
5
6function * coroutine() {
7        while ( true ) {
8                yield
9        }
10}
11cor = coroutine()
12
13for ( var i = 0; i < times; i += 1 ) { // warm JIT
14        cor.next();
15}
16
17var hrstart = process.hrtime()
18for ( var i = 0; i < times; i += 1 ) {
19        cor.next();
20}
21hrend = process.hrtime( hrstart )
22var dur = (1000000000 * hrend[0] + hrend[1]) / times
23console.log( dur )
24
25// Local Variables: //
26// tab-width: 4 //
27// compile-command: "nodejs node_cor.js" //
28// End: //
Note: See TracBrowser for help on using the repository browser.