ADT
arm-eh
ast-experimental
enum
forall-pointer-decay
jacob/cs343-translation
new-ast-unique-expr
pthread-emulation
qualifiedEnum
|
Last change
on this file since 751e2eb 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
|
| Line | |
|---|
| 1 | var times = 5000000
|
|---|
| 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 |
|
|---|
| 6 | function instant() {
|
|---|
| 7 | return new Promise(function(rs) {
|
|---|
| 8 | setImmediate(rs);
|
|---|
| 9 | });
|
|---|
| 10 | }
|
|---|
| 11 |
|
|---|
| 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 | }
|
|---|
| 20 |
|
|---|
| 21 | l();
|
|---|
| 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.