source: benchmark/ctxswitch/node_await.js @ 0dedf027

ADTarm-ehast-experimentalenumforall-pointer-decayjacob/cs343-translationnew-astnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change on this file since 0dedf027 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
RevLine 
[8633485b]1var times = 5000000
[7ac3151]2var argc = process.argv.length // node, path
3if ( argc > 3 ) process.exit( 1 )
4if ( argc == 3 ) times = Number( process.argv[2] )
5
[8633485b]6function instant() {
7     return new Promise(function(rs) {
8         setImmediate(rs);
9     });
[7ac3151]10}
11
[8633485b]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}
[7ac3151]20
[8633485b]21l();
[7ac3151]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.