2024-01-01 14:58:21 -05:00
|
|
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
2023-01-13 02:51:32 -05:00
|
|
|
//
|
|
|
|
// From https://github.com/just-js/benchmarks/tree/main/01-stdio
|
2022-12-02 01:05:18 -05:00
|
|
|
|
2024-08-20 15:14:37 -04:00
|
|
|
// deno-lint-ignore-file no-console
|
|
|
|
|
2022-12-02 01:05:18 -05:00
|
|
|
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}`);
|