Created
June 28, 2020 16:27
-
-
Save youurayy/18553475c5a9f81a17345cddeebc5d08 to your computer and use it in GitHub Desktop.
will read un-gzipped test data from https://github.com/pkg/json/tree/master/testdata; run as: deno run -A test-deno.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { readJsonSync } | |
from "https://deno.land/std/fs/mod.ts"; | |
const repetitions = 100 | |
const dir = './testdata' | |
for(const file of Deno.readDirSync(dir)) { | |
const fileName = `${dir}/${file.name}` | |
const bytes = Deno.statSync(fileName).size | |
let i = 1, avg = 0 | |
for(; i <= repetitions; i++) { | |
const t = Date.now() | |
const parsed = readJsonSync(fileName) | |
const duration = Date.now() - t | |
avg += duration | |
} | |
avg /= i | |
const mbs = '' + Math.round((bytes / 1e6) / (avg / 1000)) | |
const avgMs = '' + Math.round(avg) | |
console.log(` ${file.name.padEnd(20, ' ')} --> ` + | |
`${avgMs.padStart(4, ' ')} ms, ` + | |
`${mbs.padStart(4, ' ')} MB/s`) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment