source: benchmark/ctxswitch/node_await.js @ bb336a6

Last change on this file since bb336a6 was 8633485b, checked in by Peter A. Buhr <pabuhr@…>, 5 years ago

update Nodejs experiment for concurrency paper

  • Property mode set to 100644
File size: 590 bytes
Line 
1var times = 5000000
2var argc = process.argv.length // node, path
3if ( argc > 3 ) process.exit( 1 )
4if ( argc == 3 ) times = Number( process.argv[2] )
5
6function instant() {
7     return new Promise(function(rs) {
8         setImmediate(rs);
9     });
10}
11
12async function l() {
13    var hrstart = process.hrtime()
14    for ( var i = 0; i < times; i += 1 )
15         await instant();
16        hrend = process.hrtime( hrstart )
17        var dur = (1000000000 * hrend[0] + hrend[1]) / times
18        console.log( dur )
19}
20
21l();
22
23// Local Variables: //
24// tab-width: 4 //
25// compile-command: "nodejs node_await.js" //
26// End: //
Note: See TracBrowser for help on using the repository browser.