@@ -191,7 +191,7 @@ greeter.sayHello({ name: 'you' }, function(err, response) {
191
191
});
192
192
```
193
193
194
- To make this work, all you have to do is provide an ` rpcImpl ` , which is is an asynchronous function that takes the reflected service method, the binary HelloRequest and a node-style callback as its parameters. For example:
194
+ To make this work, all you have to do is provide an ` rpcImpl ` , which is an asynchronous function that takes the reflected service method, the binary HelloRequest and a node-style callback as its parameters. For example:
195
195
196
196
``` js
197
197
function rpcImpl (method , requestData , callback ) {
@@ -219,7 +219,7 @@ The library exports a flat `protobuf` namespace with the following members, orde
219
219
220
220
### Parser
221
221
222
- * ** load(filename: ` string|Array ` , [ root: ` Root ` ] , [ callback: ` function(err: Error, [root: Root]) ` ] ): ` Promise|undefined ` ** [[ source] ( https://github.com/dcodeIO/protobuf.js/blob/master/src/index.js )] <br />
222
+ * ** load(filename: ` string|string[] ` , [ root: ` Root ` ] , [ callback: ` function(err: Error, [root: Root]) ` ] ): ` Promise|undefined ` ** [[ source] ( https://github.com/dcodeIO/protobuf.js/blob/master/src/index.js )] <br />
223
223
Loads one or multiple .proto or preprocessed .json files into a common root namespace.
224
224
225
225
* ** loadSync(filename: ` string|string[] ` , [ root: ` Root ` ] ): ` Root ` ** [[ source] ( https://github.com/dcodeIO/protobuf.js/blob/master/src/index.js )] <br />
@@ -234,10 +234,10 @@ The library exports a flat `protobuf` namespace with the following members, orde
234
234
* ** package: ` string|undefined ` ** <br />
235
235
The package name, if declared.
236
236
237
- * ** imports: ` Array |undefined` ** <br />
237
+ * ** imports: ` string[] |undefined` ** <br />
238
238
File names of imported files, if any.
239
239
240
- * ** weakImports: ` Array |undefined` ** <br />
240
+ * ** weakImports: ` string[] |undefined` ** <br />
241
241
File names of weakly imported files, if any.
242
242
243
243
* ** syntax: ` string|undefined ` ** <br />
@@ -413,33 +413,33 @@ The package includes a benchmark that tries to compare performance to native JSO
413
413
```
414
414
benchmarking encoding performance ...
415
415
416
- Type.encode to buffer x 471,717 ops/sec ±1.30 % (91 runs sampled)
417
- JSON.stringify to string x 310,406 ops/sec ±1.00 % (90 runs sampled)
418
- JSON.stringify to buffer x 172,766 ops/sec ±1.20 % (84 runs sampled)
416
+ Type.encode to buffer x 479,876 ops/sec ±0.64 % (92 runs sampled)
417
+ JSON.stringify to string x 311,489 ops/sec ±0.84 % (87 runs sampled)
418
+ JSON.stringify to buffer x 175,079 ops/sec ±1.48 % (82 runs sampled)
419
419
420
420
Type.encode to buffer was fastest
421
- JSON.stringify to string was 34.0 % slower
422
- JSON.stringify to buffer was 63.3 % slower
421
+ JSON.stringify to string was 35.2 % slower
422
+ JSON.stringify to buffer was 63.8 % slower
423
423
424
424
benchmarking decoding performance ...
425
425
426
- Type.decode from buffer x 1,285,867 ops/sec ±0.70 % (90 runs sampled)
427
- JSON.parse from string x 292,106 ops/sec ±1.00 % (89 runs sampled)
428
- JSON.parse from buffer x 259,361 ops/sec ±0.92 % (90 runs sampled)
426
+ Type.decode from buffer x 1,267,612 ops/sec ±1.18 % (90 runs sampled)
427
+ JSON.parse from string x 291,707 ops/sec ±1.12 % (92 runs sampled)
428
+ JSON.parse from buffer x 262,640 ops/sec ±0.77 % (89 runs sampled)
429
429
430
430
Type.decode from buffer was fastest
431
- JSON.parse from string was 77.4 % slower
432
- JSON.parse from buffer was 79.9 % slower
431
+ JSON.parse from string was 77.0 % slower
432
+ JSON.parse from buffer was 79.2 % slower
433
433
434
434
benchmarking combined performance ...
435
435
436
- Type to/from buffer x 238,382 ops/sec ±0.96 % (89 runs sampled)
437
- JSON to/from string x 127,352 ops/sec ±0.73 % (93 runs sampled)
438
- JSON to/from buffer x 89,593 ops/sec ±0.85 % (87 runs sampled)
436
+ Type to/from buffer x 248,897 ops/sec ±0.89 % (90 runs sampled)
437
+ JSON to/from string x 126,848 ops/sec ±0.75 % (92 runs sampled)
438
+ JSON to/from buffer x 89,854 ops/sec ±0.79 % (93 runs sampled)
439
439
440
440
Type to/from buffer was fastest
441
- JSON to/from string was 46.5 % slower
442
- JSON to/from buffer was 62.4 % slower
441
+ JSON to/from string was 49.0 % slower
442
+ JSON to/from buffer was 63.9 % slower
443
443
```
444
444
445
445
Note that JSON is a native binding nowadays and as such is about as fast as it possibly can get. So, how can protobuf.js be faster?
0 commit comments