ADT
        arm-eh
        ast-experimental
        enum
        forall-pointer-decay
        jacob/cs343-translation
        new-ast
        new-ast-unique-expr
        pthread-emulation
        qualifiedEnum
      
      
        
          | Last change
 on this file since b52abe0 was             8633485b, checked in by Peter A. Buhr <pabuhr@…>, 6 years ago | 
        
          | 
update Nodejs experiment for concurrency paper
 | 
        
          | 
              
Property                 mode
 set to                 100644 | 
        
          | File size:
            590 bytes | 
      
      
| Rev | Line |  | 
|---|
| [8633485b] | 1 | var times = 5000000 | 
|---|
| [7ac3151] | 2 | var argc = process.argv.length // node, path | 
|---|
|  | 3 | if ( argc > 3 ) process.exit( 1 ) | 
|---|
|  | 4 | if ( argc == 3 ) times = Number( process.argv[2] ) | 
|---|
|  | 5 |  | 
|---|
| [8633485b] | 6 | function instant() { | 
|---|
|  | 7 | return new Promise(function(rs) { | 
|---|
|  | 8 | setImmediate(rs); | 
|---|
|  | 9 | }); | 
|---|
| [7ac3151] | 10 | } | 
|---|
|  | 11 |  | 
|---|
| [8633485b] | 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 | } | 
|---|
| [7ac3151] | 20 |  | 
|---|
| [8633485b] | 21 | l(); | 
|---|
| [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.