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

feat: try to use crypto.hash first #62

Merged
merged 3 commits into from
Mar 13, 2024
Merged

feat: try to use crypto.hash first #62

merged 3 commits into from
Mar 13, 2024

Conversation

fengmk2
Copy link
Member

@fengmk2 fengmk2 commented Mar 13, 2024

This can be 1.2-2x faster than the object-based createHash() for smaller inputs (<= 5MB)
https://nodejs.org/en/blog/release/v21.7.0#crypto-implement-cryptohash

> This can be 1.2-2x faster than the object-based createHash() for smaller inputs (<= 5MB)
> https://nodejs.org/en/blog/release/v21.7.0#crypto-implement-cryptohash
@fengmk2
Copy link
Member Author

fengmk2 commented Mar 13, 2024

性能不错

createHashWithMD5(Buffer.alloc(1024)) x 326,358 ops/sec ±6.30% (87 runs sampled)
crypto.hash('md5', Buffer.alloc(1024)) x 398,592 ops/sec ±4.41% (94 runs sampled)

createHashWithSHA512(Buffer.alloc(1024)) x 582,285 ops/sec ±1.76% (90 runs sampled)
crypto.hash('sha512', Buffer.alloc(1024)) x 727,549 ops/sec ±6.64% (90 runs sampled)

@fengmk2 fengmk2 merged commit 2a68056 into master Mar 13, 2024
11 checks passed
@fengmk2 fengmk2 deleted the use-hash-first branch March 13, 2024 02:32
fengmk2 pushed a commit that referenced this pull request Mar 13, 2024
[skip ci]

## [2.1.0](v2.0.0...v2.1.0) (2024-03-13)

### Features

* try to use crypto.hash first ([#62](#62)) ([2a68056](2a68056))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant