| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
@gxcsoccer, thanks for your PR! By analyzing the history of the files in this pull request, we identified @dead-horse and @fengmk2 to be potential reviewers. |
Sorry, something went wrong.
| * @api public | ||
| */ | ||
| proto.readNull = function () { | ||
| this._checkLabel('readNull', 'N'); |
There was a problem hiding this comment.
如果把 readNull,readInt 等这种 api 都变成私有的,只暴露 read,那 checkLabel 这个是没必要的
Sorry, something went wrong.
| var code = this.byteBuffer.get(); | ||
| if (code === 0x4a) { | ||
| return new Date(utils.handleLong(this.byteBuffer.getLong())); | ||
| return new Date(this.byteBuffer.getLong().toNumber()); |
There was a problem hiding this comment.
针对 date,直接 toNumber 就好了
Sorry, something went wrong.
| head = this.byteBuffer.get(); | ||
| l = utils.lengthOfUTF8(head); | ||
| this.byteBuffer.skip(l - 1); | ||
| ch = this.byteBuffer.get(); |
There was a problem hiding this comment.
这个改完会有多大性能提升?
Sorry, something went wrong.
There was a problem hiding this comment.
少了一次循环,我之前有测,==
Sorry, something went wrong.
There was a problem hiding this comment.
优化前
hessian2 decode: string x 1,251,833 ops/sec ±1.35% (86 runs sampled)
优化后
hessian2 decode: string x 1,482,684 ops/sec ±1.29% (85 runs sampled)
Sorry, something went wrong.
这俩组数据要在同一台机器 && Node.js version 上跑才有意义。我试一下我的机器 && node 8-pre |
Sorry, something went wrong.
|
@gxcsoccer 同一台机器,同样的 node 版本下: node version: v8.0.0-pre hessian2 decode: number x 4,721,288 ops/sec ±0.54% (87 runs sampled) hessian2 decode: date x 2,599,811 ops/sec ±0.61% (92 runs sampled) hessian2 decode: string x 557,185 ops/sec ±1.01% (88 runs sampled) Fast hessian2 decode: number x 9,706,914 ops/sec ±1.41% (84 runs sampled) Fast hessian2 decode: date x 3,861,312 ops/sec ±1.18% (86 runs sampled) Fast hessian2 decode: string x 1,671,423 ops/sec ±5.69% (60 runs sampled) |
Sorry, something went wrong.
| */ | ||
| proto.init = function (buf) { | ||
| this.byteBuffer = ByteBuffer.wrap(buf); | ||
| this.byteBuffer._bytes = buf; |
There was a problem hiding this comment.
为何要使用这种私有 api?
Sorry, something went wrong.
There was a problem hiding this comment.
this.byteBuffer.reset(buf) 这种不是更好?
Sorry, something went wrong.
There was a problem hiding this comment.
reset 没有入参,这里是 WIP,还不是最终版本,先找到优化点,后面可以针对性的对 api 做调整
ByteBuffer.prototype.reset = function () {
this._offset = 0;
};
Sorry, something went wrong.
|
ci 加上 node 7 |
Sorry, something went wrong.
Codecov Report
@@ Coverage Diff @@
## master #74 +/- ##
==========================================
- Coverage 96.09% 95.51% -0.58%
==========================================
Files 7 7
Lines 1076 1093 +17
Branches 202 204 +2
==========================================
+ Hits 1034 1044 +10
- Misses 42 49 +7
Continue to review full report at Codecov.
|
Sorry, something went wrong.
|
优化前 Hessian Decode Benchmark node version: v7.10.0, date: Thu May 11 2017 16:53:41 GMT+0800 (CST) Starting... 3 tests completed. hessian2 decode: number x 1,647,104 ops/sec ±1.51% (83 runs sampled) hessian2 decode: date x 412,326 ops/sec ±2.43% (81 runs sampled) hessian2 decode: string x 169,817 ops/sec ±1.93% (84 runs sampled) 优化后 Hessian Decode Benchmark node version: v7.10.0, date: Thu May 11 2017 16:54:07 GMT+0800 (CST) Starting... 3 tests completed. hessian2 decode: number x 9,965,533 ops/sec ±2.19% (85 runs sampled) hessian2 decode: date x 3,342,223 ops/sec ±2.62% (81 runs sampled) hessian2 decode: string x 1,272,044 ops/sec ±1.73% (84 runs sampled) |
Sorry, something went wrong.
|
number 和 string 的优化主要来自于 byte.get node-modules/byte#25 |
Sorry, something went wrong.
hessian2 decode: number x 9,840,410 ops/sec ±1.10% (92 runs sampled) hessian2 decode: date x 3,965,427 ops/sec ±0.47% (90 runs sampled) hessian2 decode: string x 1,473,963 ops/sec ±0.72% (91 runs sampled) Fast hessian2 decode: number x 10,883,935 ops/sec ±1.01% (91 runs sampled) Fast hessian2 decode: date x 4,356,561 ops/sec ±0.88% (90 runs sampled) Fast hessian2 decode: string x 1,886,761 ops/sec ±4.78% (62 runs sampled) |
Sorry, something went wrong.
|
💯 确实性能和 fast hessian2 差不多了 |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
初步优化了下 number, date 和 string,性能和孝达的 fast hessian2 差不多了