-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Performance improvement #74
Conversation
Just change (source[psz]) to (psz < source.length) in line 82.
can you show any benchmarks? |
`const rand = (a, b) => { let buffer = Buffer.alloc(16); let t1 = new Date().getTime(); //cpu i9-9900kf //use present (source[psz]) //change to (psz < source.length) ` |
This makes a ton of sense to me. Any objection to merging this? |
The effect on Before: ~/src/base-x/benchmark$ (cd ../ && npm run build) && SEED=8854dc2a353e143702ef1b29874b63a4 npm start
> base-x@4.0.0 build
> tsc -p ./tsconfig.json ; standard --fix
> base-x-benchmark@0.0.0 start
> node index.js
Seed: 8854dc2a353e143702ef1b29874b63a4
--------------------------------------------------
encode x 389,085 ops/sec ±0.34% (9 runs sampled)
decode x 427,013 ops/sec ±0.31% (8 runs sampled)
================================================== After: ~/src/base-x/benchmark$ (cd ../ && npm run build) && SEED=8854dc2a353e143702ef1b29874b63a4 npm start
> base-x@4.0.0 build
> tsc -p ./tsconfig.json ; standard --fix
> base-x-benchmark@0.0.0 start
> node index.js
Seed: 8854dc2a353e143702ef1b29874b63a4
--------------------------------------------------
encode x 389,681 ops/sec ±0.32% (8 runs sampled)
decode x 448,309 ops/sec ±0.09% (9 runs sampled)
================================================== |
Feel like slamming this in, @junderw? This should make tons of downstream deps faster! |
Travis CI is broken, needs to be moved to Github CI. |
This yields a performance improvement over indexing into `source` over and over. `source` is asserted to be a string, `psz` is monotonically increasing, and `psz >= source.length` is a good indication that you've run out of characters. Originally proposed by @oscxc in cryptocoinjs#74.
This yields a performance improvement over indexing into `source` over and over. `source` is asserted to be a string, `psz` is monotonically increasing, and `psz >= source.length` is a good indication that you've run out of characters. Originally proposed by @oscxc in cryptocoinjs#74.
This yields a performance improvement over indexing into `source` over and over. `source` is asserted to be a string, `psz` is monotonically increasing, and `psz >= source.length` is a good indication that you've run out of characters. Originally proposed by @oscxc in cryptocoinjs#74. Co-authored-by: Rand <15077550@qq.com>
This yields a performance improvement over indexing into `source` over and over. `source` is asserted to be a string, `psz` is monotonically increasing, and `psz >= source.length` is a good indication that you've run out of characters. Originally proposed by @oscxc in cryptocoinjs#74. Co-authored-by: Rand <15077550@qq.com>
This yields a performance improvement over indexing into `source` over and over. `source` is asserted to be a string, `psz` is monotonically increasing, and `psz >= source.length` is a good indication that you've run out of characters. Originally proposed by @oscxc in #74. Co-authored-by: Rand <15077550@qq.com>
Just change (source[psz]) to (psz < source.length) in line 82.