Changeset 6f302cd for benchmark/ctxswitch
- Timestamp:
- Jan 30, 2020, 10:59:21 PM (3 years ago)
- Branches:
- arm-eh, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation
- Children:
- c334ecd
- Parents:
- 8a13c47 (diff), 8633485b (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
benchmark/ctxswitch/node_await.js
r8a13c47 r6f302cd 1 var times = 10000001 var times = 5000000 2 2 var argc = process.argv.length // node, path 3 3 if ( argc > 3 ) process.exit( 1 ) 4 4 if ( argc == 3 ) times = Number( process.argv[2] ) 5 5 6 var p = new Promise( 7 function( rs ) { 8 resolve = rs; 9 } 10 ); 11 12 for ( var i = 0; i < times; i += 1 ) { 13 p = p.then( 14 () => { return } 15 ); 6 function instant() { 7 return new Promise(function(rs) { 8 setImmediate(rs); 9 }); 16 10 } 17 11 18 p = p.then( 19 () => { 20 hrend = process.hrtime( hrstart ) 21 var dur = (1000000000 * hrend[0] + hrend[1]) / times 22 console.log( dur ) 23 } 24 ); 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 } 25 20 26 var hrstart = process.hrtime() 27 resolve(); 21 l(); 28 22 29 23 // Local Variables: //
Note: See TracChangeset
for help on using the changeset viewer.