Skip to content

Commit

Permalink
Added asJSON bytes as Buffer, see #566; Fixed parsing enum inner opti…
Browse files Browse the repository at this point in the history
…ons, see #565; Other minor optimizations
  • Loading branch information
dcodeIO committed Dec 17, 2016
1 parent ea7ba8b commit 9c9a66b
Show file tree
Hide file tree
Showing 20 changed files with 332 additions and 244 deletions.
26 changes: 17 additions & 9 deletions bench/prof.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,24 @@ var protobuf = require("..");

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

var root = protobuf.parse(fs.readFileSync(require.resolve("../bench/bench.proto")).toString("utf8")).root;
var Test = root.lookup("Test");
var data = require("../bench/bench.json");

// Alternative mapbox data
/* var root = protobuf.parse(fs.readFileSync(require.resolve("../tests/data/mapbox/vector_tile.proto")).toString("utf8")).root;
var Test = root.lookup("vector_tile.Tile");
var data = Test.decode(fs.readFileSync(require.resolve("../tests/data/mapbox/vector_tile.bin")));*/
var root, Test, data, count;
if (process.argv.indexOf("--alt") < 0) {
root = protobuf.parse(fs.readFileSync(require.resolve("../bench/bench.proto")).toString("utf8")).root;
Test = root.lookup("Test");
data = require("../bench/bench.json");
count = 10000000;
process.stdout.write("bench.proto");
} else {
root = protobuf.parse(fs.readFileSync(require.resolve("../tests/data/mapbox/vector_tile.proto")).toString("utf8")).root;
Test = root.lookup("vector_tile.Tile");
data = Test.decode(fs.readFileSync(require.resolve("../tests/data/mapbox/vector_tile.bin")));
count = 1000;
process.stdout.write("vector_tile.proto");
}

var count = process.argv.length > 3 ? parseInt(process.argv[3], 10) : 10000000;
if (process.argv.length > 3 && /^\d+$/.test(process.argv[3]))
count = parseInt(process.argv[3], 10);
console.log(" x " + count);

function setupBrowser() {
protobuf.Writer.create = function create_browser() { return new protobuf.Writer(); };
Expand Down
Loading

0 comments on commit 9c9a66b

Please sign in to comment.