Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Benchmark with GB/s columns #33

Merged
merged 1 commit into from
Apr 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 19 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,23 +64,25 @@ npm install
npm run benchmark
```

| filename | filesize (MB) | JSON.parse (ms) | simdjson.parse (ms) | X faster |
| :------- | ------------: | --------------: | ------------------: | -------: |
| apache_builds.json | 0.13 | 0.305 | 0.146 | 2.09 |
| canada.json | 2.25 | 13.914 | 5.475 | 2.54 |
| citm_catalog.json | 1.73 | 4.820 | 6.470 | 0.74 |
| github_events.json | 0.07 | 8.310 | 0.085 | 97.91 |
| gsoc_2018.json | 3.33 | 6.029 | 3.255 | 1.85 |
| instruments.json | 0.22 | 0.464 | 0.271 | 1.71 |
| marine_ik.json | 2.98 | 19.533 | 7.133 | 2.74 |
| mesh_pretty.json | 1.58 | 3.987 | 1.985 | 2.01 |
| mesh.json | 0.72 | 2.869 | 1.363 | 2.10 |
| numbers.json | 0.15 | 0.729 | 0.244 | 2.99 |
| random.json | 0.51 | 1.859 | 1.983 | 0.94 |
| sf_citylots.json | 189.78 | 1880.563 | 569.580 | 3.30 |
| twitter.json | 0.63 | 1.633 | 2.093 | 0.78 |
| twitterescaped.json | 0.56 | 2.051 | 0.831 | 2.47 |
| update_center.json | 0.53 | 3.410 | 2.132 | 1.60 |
| filename | filesize (MB) | JSON.parse(ms) | simdjson.lazyParse (ms) | JSON.parse (GB/s) | simdjson.lazyParse (GB/s) | X faster |
| :-- | --: | --: | --: | --: | --: | --: |
| apache_builds.json | 0.13 | 0.303 | 0.158 | 0.42 | 0.80 | 1.91 |
| canada.json | 2.25 | 14.332 | 7.584 | 0.16 | 0.30 | 1.89 |
| citm_catalog.json | 1.73 | 5.387 | 5.768 | 0.32 | 0.30 | 0.93 |
| github_events.json | 0.07 | 0.192 | 0.091 | 0.34 | 0.71 | 2.10 |
| gsoc_2018.json | 3.33 | 5.420 | 3.839 | 0.61 | 0.87 | 1.41 |
| instruments.json | 0.22 | 0.673 | 0.619 | 0.33 | 0.36 | 1.09 |
| marine_ik.json | 2.98 | 13.169 | 6.397 | 0.23 | 0.47 | 2.06 |
| mesh_pretty.json | 1.58 | 5.704 | 3.043 | 0.28 | 0.52 | 1.87 |
| mesh.json | 0.72 | 2.856 | 1.404 | 0.25 | 0.52 | 2.03 |
| numbers.json | 0.15 | 0.643 | 0.280 | 0.23 | 0.54 | 2.30 |
| random.json | 0.51 | 1.914 | 2.447 | 0.27 | 0.21 | 0.78 |
| sf_citylots.json | 189.78 | 1492.166 | 709.692 | 0.13 | 0.27 | 2.10 |
| twitter.json | 0.63 | 1.621 | 2.112 | 0.39 | 0.30 | 0.77 |
| twitterescaped.json | 0.56 | 1.924 | 0.959 | 0.29 | 0.59 | 2.01 |
| update_center.json | 0.53 | 2.803 | 2.715 | 0.19 | 0.20 | 1.03 |

Results from a 2018 MacBook Pro with 2.3GHz Intel Core i9.

### Ops/sec

Expand Down
35 changes: 29 additions & 6 deletions benchmark/benchmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,41 @@ suite
console.log(`${event.target} => ${(event.target.times.period * 1000).toFixed(3)}ms`)
})
.on(`complete`, function() {
const columns = [
`filename`,
`filesize (MB)`,
`JSON.parse(ms)`,
`simdjson.lazyParse (ms)`,
`JSON.parse (GB/s)`,
`simdjson.lazyParse (GB/s)`,
`X faster`,
];

console.log(``);
console.log(`| filename | filesize (MB) | JSON.parse (ms) | simdjson.parse (ms) | X faster |`);
console.log(`| :------- | ------------: | --------------: | ------------------: | -------: |`);
console.log(`| ${columns.join(` | `)} |`);
// filename is left aligned, numbers are right aligned
console.log(`| ${columns.map(col => col === `filename` ? `:--` : `--:`).join(` | `)} |`)

const benches = this.filter(() => true);
for (var i = 0; i < benches.length; i+=2) {
const fileName = benches[i].name.split(`#`)[0];
const fileSize = Buffer.byteLength(jsonExamples[fileName.split(`.`)[0]]) / 1e6;
const simdParsePeriod = benches[i].times.period * 1000;
const jsonParsePeriod = benches[i + 1].times.period * 1000;
const xFaster = jsonParsePeriod / simdParsePeriod;
console.log(`| ${fileName} | ${fileSize.toFixed(2)} | ${jsonParsePeriod.toFixed(3)} | ${simdParsePeriod.toFixed(3)} | ${xFaster.toFixed(2)} |`);
const jsonParseMs = benches[i + 1].times.period * 1000;
const simdLazyParseMs = benches[i].times.period * 1000;
const jsonParseGbps = fileSize / jsonParseMs;
const simdjsonLazyParseGbps = fileSize / simdLazyParseMs;
const xFaster = jsonParseMs / simdLazyParseMs;
const row = [
fileName,
fileSize.toFixed(2),
jsonParseMs.toFixed(3),
simdLazyParseMs.toFixed(3),
jsonParseGbps.toFixed(2),
simdjsonLazyParseGbps.toFixed(2),
xFaster.toFixed(2),
];

console.log(`| ${row.join(` | `)} |`);
}
})
.run({async: false });
Expand Down