@@ -42,16 +42,24 @@ var protobuf = require("..");
4242
4343// protobuf.util.codegen.verbose = true;
4444
45- var root = protobuf . parse ( fs . readFileSync ( require . resolve ( "../bench/bench.proto" ) ) . toString ( "utf8" ) ) . root ;
46- var Test = root . lookup ( "Test" ) ;
47- var data = require ( "../bench/bench.json" ) ;
48-
49- // Alternative mapbox data
50- /* var root = protobuf.parse(fs.readFileSync(require.resolve("../tests/data/mapbox/vector_tile.proto")).toString("utf8")).root;
51- var Test = root.lookup("vector_tile.Tile");
52- var data = Test.decode(fs.readFileSync(require.resolve("../tests/data/mapbox/vector_tile.bin")));*/
45+ var root , Test , data , count ;
46+ if ( process . argv . indexOf ( "--alt" ) < 0 ) {
47+ root = protobuf . parse ( fs . readFileSync ( require . resolve ( "../bench/bench.proto" ) ) . toString ( "utf8" ) ) . root ;
48+ Test = root . lookup ( "Test" ) ;
49+ data = require ( "../bench/bench.json" ) ;
50+ count = 10000000 ;
51+ process . stdout . write ( "bench.proto" ) ;
52+ } else {
53+ root = protobuf . parse ( fs . readFileSync ( require . resolve ( "../tests/data/mapbox/vector_tile.proto" ) ) . toString ( "utf8" ) ) . root ;
54+ Test = root . lookup ( "vector_tile.Tile" ) ;
55+ data = Test . decode ( fs . readFileSync ( require . resolve ( "../tests/data/mapbox/vector_tile.bin" ) ) ) ;
56+ count = 1000 ;
57+ process . stdout . write ( "vector_tile.proto" ) ;
58+ }
5359
54- var count = process . argv . length > 3 ? parseInt ( process . argv [ 3 ] , 10 ) : 10000000 ;
60+ if ( process . argv . length > 3 && / ^ \d + $ / . test ( process . argv [ 3 ] ) )
61+ count = parseInt ( process . argv [ 3 ] , 10 ) ;
62+ console . log ( " x " + count ) ;
5563
5664function setupBrowser ( ) {
5765 protobuf . Writer . create = function create_browser ( ) { return new protobuf . Writer ( ) ; } ;
0 commit comments