Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • benchmark/ctxswitch/node_await.js

    r8633485b r7ac3151  
    1 var times = 5000000
     1var times = 1000000
    22var argc = process.argv.length // node, path
    33if ( argc > 3 ) process.exit( 1 )
    44if ( argc == 3 ) times = Number( process.argv[2] )
    55
    6 function instant() {
    7      return new Promise(function(rs) {
    8          setImmediate(rs);
    9      });
     6var p = new Promise(
     7    function( rs ) {
     8                resolve = rs;
     9    }
     10);
     11
     12for ( var i = 0; i < times; i += 1 ) {
     13    p = p.then(
     14                () => { return }
     15    );
    1016}
    1117
    12 async 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 }
     18p = p.then(
     19    () => {
     20                hrend = process.hrtime( hrstart )
     21                var dur = (1000000000 * hrend[0] + hrend[1]) / times
     22                console.log( dur )
     23    }
     24);
    2025
    21 l();
     26var hrstart = process.hrtime()
     27resolve();
    2228
    2329// Local Variables: //
Note: See TracChangeset for help on using the changeset viewer.