Skip to content

Commit 3317a76

Browse files
committed
Other: Fixed some common reflection deopt sites, see #653
1 parent cdfe6bf commit 3317a76

31 files changed

+1898
-248
lines changed

bench/prof.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,21 @@ var protobuf = require("..");
4444

4545
// protobuf.util.codegen.verbose = true;
4646

47-
var root, Test, data, count;
47+
var root, json;
48+
49+
if (process.argv[2] === "fromjson") {
50+
json = require("../tests/data/test.json");
51+
if (process.argv.indexOf("--resolve") < 0)
52+
for (var k = 0; k < 10000; ++k)
53+
protobuf.Root.fromJSON(json);
54+
else
55+
for (var l = 0; l < 10000; ++l)
56+
protobuf.Root.fromJSON(json).resolveAll();
57+
return;
58+
}
59+
60+
var Test, data, count;
61+
4862
if (process.argv.indexOf("--alt") < 0) {
4963
root = protobuf.parse(fs.readFileSync(require.resolve("../bench/bench.proto")).toString("utf8")).root;
5064
Test = root.lookup("Test");
@@ -59,7 +73,6 @@ if (process.argv.indexOf("--alt") < 0) {
5973
count = 1000;
6074
process.stdout.write("vector_tile.proto");
6175
}
62-
var json = JSON.stringify(root);
6376

6477
if (process.argv.length > 3 && /^\d+$/.test(process.argv[3]))
6578
count = parseInt(process.argv[3], 10);
@@ -86,8 +99,4 @@ switch (process.argv[2]) {
8699
for (var j = 0; j < count; ++j)
87100
Test.decode(buf);
88101
break;
89-
case "fromjson":
90-
for (var k = 0; k < 100000000; ++k)
91-
protobuf.Root.fromJSON(json).resolveAll();
92-
break;
93102
}

0 commit comments

Comments
 (0)