diff options
Diffstat (limited to 'cli/bench/stdio/stdio.js')
-rw-r--r-- | cli/bench/stdio/stdio.js | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/cli/bench/stdio/stdio.js b/cli/bench/stdio/stdio.js new file mode 100644 index 000000000..0663d6fd7 --- /dev/null +++ b/cli/bench/stdio/stdio.js @@ -0,0 +1,16 @@ +// From https://github.com/just-js/benchmarks/tree/main/01-stdio +// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. + +const blocksize = parseInt(Deno.args[0] || 65536); +const buf = new Uint8Array(blocksize); +let size = 0; +let reads = 0; + +let n = Deno.stdin.readSync(buf); +while (n > 0) { + reads++; + size += n; + n = Deno.stdin.readSync(buf); +} +if (n < 0) throw new Error("Bad Read"); +console.log(`size ${size} reads ${reads} blocksize ${blocksize}`); |