Skip to content

Commit ebbbcaa

Browse files
Improve shared benchmark
1 parent d286a8e commit ebbbcaa

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

bench/index.js

+12-14
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,6 @@ newSuite("combined")
9191
.run();
9292

9393
var json = require("../tests/data/test.json");
94-
var fromJsonRoot = protobuf.Root.fromJSON(json);
95-
var fromJsonIndex = 1;
96-
9794
newSuite("fromJSON")
9895
.add("isolated", function() {
9996
protobuf.Root.fromJSON(json);
@@ -102,20 +99,21 @@ newSuite("fromJSON")
10299
protobuf.Root.fromJSON(json).resolveAll();
103100
})
104101
.add("shared (unique)", function() {
105-
var jsonCopy = {
106-
options: json.options,
107-
nested: {}
108-
};
109-
Object.keys(json).forEach(key => {
110-
jsonCopy.nested[key + fromJsonIndex] = json[key];
111-
});
112-
fromJsonIndex++;
113-
114-
protobuf.Root.fromJSON(jsonCopy, fromJsonRoot);
102+
var root = protobuf.Root.fromJSON(json);
103+
for (var i = 0; i < 1000; ++i) {
104+
var jsonCopy = {
105+
options: json.options,
106+
nested: {}
107+
};
108+
Object.keys(json).forEach(key => {
109+
jsonCopy.nested[key + i] = json[key];
110+
});
111+
112+
protobuf.Root.fromJSON(jsonCopy, root);
113+
}
115114
}).run();
116115

117116
var resolveAllRoot = protobuf.Root.fromJSON(json);
118-
119117
newSuite("resolveAll")
120118
.add("isolated", function() {
121119
resolveAllRoot.resolveAll();

0 commit comments

Comments
 (0)