Skip to content

Commit 7b3bdb5

Browse files
committed
Other: Output more human friendly metrics from benchmark
1 parent 59e4478 commit 7b3bdb5

File tree

2 files changed

+32
-31
lines changed

2 files changed

+32
-31
lines changed

README.md

+28-28
Original file line numberDiff line numberDiff line change
@@ -700,45 +700,45 @@ The package includes a benchmark that compares protobuf.js performance to native
700700
```
701701
benchmarking encoding performance ...
702702
703-
protobuf.js (reflect) x 547,366 ops/sec ±1.29% (90 runs sampled)
704-
protobuf.js (static) x 525,722 ops/sec ±1.17% (91 runs sampled)
705-
JSON (string) x 311,180 ops/sec ±0.67% (93 runs sampled)
706-
JSON (buffer) x 183,724 ops/sec ±0.69% (92 runs sampled)
707-
google-protobuf x 76,337 ops/sec ±0.73% (91 runs sampled)
703+
protobuf.js (reflect) x 540,622 ops/sec ±0.87% (89 runs sampled)
704+
protobuf.js (static) x 537,928 ops/sec ±1.19% (91 runs sampled)
705+
JSON (string) x 317,124 ops/sec ±0.63% (91 runs sampled)
706+
JSON (buffer) x 185,945 ops/sec ±0.72% (89 runs sampled)
707+
google-protobuf x 76,552 ops/sec ±0.85% (91 runs sampled)
708708
709709
protobuf.js (reflect) was fastest
710-
protobuf.js (static) was 3.8% slower
711-
JSON (string) was 42.8% slower
712-
JSON (buffer) was 66.2% slower
713-
google-protobuf was 86.0% slower
710+
protobuf.js (static) was 0.01 times slower (-0.8% ops/sec)
711+
JSON (string) was 0.70 times slower (-41.2% ops/sec)
712+
JSON (buffer) was 1.90 times slower (-65.6% ops/sec)
713+
google-protobuf was 6.06 times slower (-85.8% ops/sec)
714714
715715
benchmarking decoding performance ...
716716
717-
protobuf.js (reflect) x 1,401,958 ops/sec ±0.78% (93 runs sampled)
718-
protobuf.js (static) x 1,391,017 ops/sec ±0.78% (90 runs sampled)
719-
JSON (string) x 301,749 ops/sec ±0.88% (93 runs sampled)
720-
JSON (buffer) x 268,792 ops/sec ±0.84% (90 runs sampled)
721-
google-protobuf x 186,727 ops/sec ±0.81% (90 runs sampled)
717+
protobuf.js (reflect) x 1,386,221 ops/sec ±0.95% (93 runs sampled)
718+
protobuf.js (static) x 1,397,599 ops/sec ±0.74% (91 runs sampled)
719+
JSON (string) x 300,667 ops/sec ±0.88% (90 runs sampled)
720+
JSON (buffer) x 265,276 ops/sec ±0.88% (90 runs sampled)
721+
google-protobuf x 162,202 ops/sec ±0.85% (92 runs sampled)
722722
723-
protobuf.js (reflect) was fastest
724-
protobuf.js (static) was 0.8% slower
725-
JSON (string) was 78.5% slower
726-
JSON (buffer) was 80.8% slower
727-
google-protobuf was 86.7% slower
723+
protobuf.js (static) was fastest
724+
protobuf.js (reflect) was 0.01 times slower (-1.0% ops/sec)
725+
JSON (string) was 3.65 times slower (-78.5% ops/sec)
726+
JSON (buffer) was 4.28 times slower (-81.0% ops/sec)
727+
google-protobuf was 7.63 times slower (-88.4% ops/sec)
728728
729729
benchmarking combined performance ...
730730
731-
protobuf.js (reflect) x 274,685 ops/sec ±0.99% (89 runs sampled)
732-
protobuf.js (static) x 278,352 ops/sec ±1.00% (90 runs sampled)
733-
JSON (string) x 129,638 ops/sec ±0.83% (91 runs sampled)
734-
JSON (buffer) x 90,904 ops/sec ±0.93% (87 runs sampled)
735-
google-protobuf x 43,327 ops/sec ±0.89% (90 runs sampled)
731+
protobuf.js (reflect) x 277,238 ops/sec ±0.95% (92 runs sampled)
732+
protobuf.js (static) x 281,732 ops/sec ±0.91% (91 runs sampled)
733+
JSON (string) x 128,615 ops/sec ±1.01% (88 runs sampled)
734+
JSON (buffer) x 89,794 ops/sec ±1.28% (88 runs sampled)
735+
google-protobuf x 40,987 ops/sec ±1.29% (90 runs sampled)
736736
737737
protobuf.js (static) was fastest
738-
protobuf.js (reflect) was 1.3% slower
739-
JSON (string) was 53.3% slower
740-
JSON (buffer) was 67.3% slower
741-
google-protobuf was 84.4% slower
738+
protobuf.js (reflect) was 0.02 times slower (-1.6% ops/sec)
739+
JSON (string) was 1.19 times slower (-54.4% ops/sec)
740+
JSON (buffer) was 2.15 times slower (-68.2% ops/sec)
741+
google-protobuf was 5.90 times slower (-85.5% ops/sec)
742742
```
743743

744744
You can also run [the benchmark](https://github.com/dcodeIO/protobuf.js/blob/master/bench/index.js) ...

bench/suite.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function newSuite(name) {
1313
benches.push(event.target);
1414
})
1515
.on("start", function() {
16-
process.stdout.write("benchmarking " + name + " performance ...\n\n");
16+
process.stdout.write(chalk.white.bold("benchmarking " + name + " performance ...") + "\n\n");
1717
})
1818
.on("cycle", function(event) {
1919
process.stdout.write(String(event.target) + "\n");
@@ -26,8 +26,9 @@ function newSuite(name) {
2626
process.stdout.write("\n" + chalk.white(pad(fastest.name, padSize)) + " was " + chalk.green("fastest") + "\n");
2727
benches.slice(1).forEach(function(bench) {
2828
var hz = getHz(bench);
29-
var percent = (1 - hz / fastestHz) * 100;
30-
process.stdout.write(chalk.white(pad(bench.name, padSize)) + " was " + chalk.red(percent.toFixed(1) + "% slower") + "\n");
29+
var percent = (1 - hz / fastestHz); // less total operations per time
30+
var factor = -(1 - fastestHz / hz); // additional time it takes to complete the same number of operations
31+
process.stdout.write(chalk.white(pad(bench.name, padSize)) + " was " + chalk.red(factor.toFixed(2) + " times slower (-" + (percent * 100).toFixed(1) + "% ops/sec)") + "\n");
3132
});
3233
}
3334
process.stdout.write("\n");

0 commit comments

Comments
 (0)