Skip to content
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

Remove DataView, just do bitops #8

Closed
feross opened this issue Dec 28, 2013 · 5 comments
Closed

Remove DataView, just do bitops #8

feross opened this issue Dec 28, 2013 · 5 comments

Comments

@feross
Copy link
Owner

feross commented Dec 28, 2013

Advantages:

  • less code
  • i'm guessing it will be faster
  • same code path for browsers that support typed arrays and those that don't
@feross
Copy link
Owner Author

feross commented Jan 1, 2014

See discussion here: browserify/sha.js@91649a6#commitcomment-4964325

@feross
Copy link
Owner Author

feross commented Jan 1, 2014

Wow, looks like it's better to just get rid of the DataView and do bit ops manually! cc @dominictarr @substack @maxogden

Perf before:

FIREFOX: "NewBuffer#readUInt32LE x 1,221,113 ops/sec ±1.41% (67 runs sampled)" 
FIREFOX: "NewBuffer#readUInt32BE x 1,156,194 ops/sec ±0.33% (68 runs sampled)"
CHROME: NewBuffer#readUInt32LE x 564,154 ops/sec ±0.26% (69 runs sampled)
CHROME: NewBuffer#readUInt32BE x 494,371 ops/sec ±0.47% (69 runs sampled)

Perf after:

FIREFOX: "NewBuffer#readUInt32LE x 1,554,848 ops/sec ±0.64% (67 runs sampled)"
FIREFOX: "NewBuffer#readUInt32BE x 1,511,584 ops/sec ±0.68% (66 runs sampled)"
CHROME: NewBuffer#readUInt32LE x 963,040 ops/sec ±0.30% (69 runs sampled)
CHROME: NewBuffer#readUInt32BE x 823,859 ops/sec ±1.19% (70 runs sampled)

Size Before:

$ browserify -r native-buffer-browserify | wc -c
   37762

Size after:

$ browserify -r native-buffer-browserify | wc -c
   34034

@feross feross closed this as completed in fa1c815 Jan 1, 2014
@feross
Copy link
Owner Author

feross commented Jan 1, 2014

Published as 2.0.2.

feross referenced this issue in browserify/sha.js Jan 1, 2014
@dominictarr
Copy link

Wat!? how come that is faster!

@feross
Copy link
Owner Author

feross commented Jan 1, 2014

No idea! My guess is that DataView isn't used much in production code yet, so the browsers haven't taken the time to optimize it heavily yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants