From 8bdb15496e321d1d73fa2b65e2ee783471816b7e Mon Sep 17 00:00:00 2001 From: LongYinan Date: Wed, 6 May 2020 12:06:23 +0800 Subject: [PATCH] perf: replace sse4_crc32 to @node-rs/crc32 --- benchmark/index.js | 4 ++++ impls/sse4_crc32c.js | 4 ++-- package.json | 5 +++-- yarn.lock | 19 +++++++++++++++++++ 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/benchmark/index.js b/benchmark/index.js index c770cc2..d481638 100644 --- a/benchmark/index.js +++ b/benchmark/index.js @@ -3,6 +3,10 @@ const Benchtable = require('benchtable'); const suite = new Benchtable(); const kTesters = [{ + name: '@node-rs/crc32c', + calculate: require('../impls/sse4_crc32c').calculate, +}, +{ name: 'sse4_crc32c_hw', calculate: require('sse4_crc32').sse42_crc, }, { diff --git a/impls/sse4_crc32c.js b/impls/sse4_crc32c.js index bdfa8e4..89dc390 100644 --- a/impls/sse4_crc32c.js +++ b/impls/sse4_crc32c.js @@ -1,5 +1,5 @@ -const sse4_crc32 = require('sse4_crc32'); +const bindings = require('@node-rs/crc32'); module.exports = { - calculate: sse4_crc32.calculate, + calculate: bindings.crc32c, }; diff --git a/package.json b/package.json index 738bde8..b4b82c3 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ }, "main": "./loader", "optionalDependencies": { - "sse4_crc32": "^6.0.1" + "@node-rs/crc32": "^0.1.7" }, "scripts": { "test": "nyc --reporter=html --reporter=text mocha", @@ -32,6 +32,7 @@ "mocha": "^6.2.1", "nyc": "^14.1.1", "random-string": "^0.2.0", - "should": "^13.2.3" + "should": "^13.2.3", + "sse4_crc32": "^6.0.1" } } diff --git a/yarn.lock b/yarn.lock index efa3f1a..ecdfc15 100644 --- a/yarn.lock +++ b/yarn.lock @@ -89,6 +89,20 @@ lodash "^4.17.13" to-fast-properties "^2.0.0" +"@node-rs/crc32@^0.1.7": + version "0.1.7" + resolved "https://registry.npmjs.org/@node-rs/crc32/-/crc32-0.1.7.tgz#dccb2147fda92d480ac3f89eac5ae4b5b77de4be" + integrity sha512-5wyTLS1zrpi5CmBZplbgIUt5mrQr+aCYo8DhBKYaTi0DzdpxMzxFfUOwxXRp6e5cLhaNdX6jk2KYrtysPi66/g== + dependencies: + "@node-rs/helper" "^0.1.3" + +"@node-rs/helper@^0.1.3": + version "0.1.3" + resolved "https://registry.npmjs.org/@node-rs/helper/-/helper-0.1.3.tgz#da94032fe44bb6a3456d81de1bcdcead1f651817" + integrity sha512-jqJ8VRRoZDyEcW7cfVintp1qytoOXJkJpMj2pBgMgyGsipWDG5USGR98iDmDDqrcB0LUhOA1xsDuEpJgUYgSzA== + dependencies: + tslib "^1.11.1" + ajv@^6.5.5: version "6.10.2" resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.10.2.tgz#d3cea04d6b017b2894ad69040fec8b623eb4bd52" @@ -1642,6 +1656,11 @@ tough-cookie@~2.4.3: psl "^1.1.24" punycode "^1.4.1" +tslib@^1.11.1: + version "1.11.2" + resolved "https://registry.npmjs.org/tslib/-/tslib-1.11.2.tgz#9c79d83272c9a7aaf166f73915c9667ecdde3cc9" + integrity sha512-tTSkux6IGPnUGUd1XAZHcpu85MOkIl5zX49pO+jfsie3eP0B6pyhOlLXm3cAC6T7s+euSDDUUV+Acop5WmtkVg== + tunnel-agent@^0.6.0: version "0.6.0" resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.6.0.tgz#27a5dea06b36b04a0a9966774b290868f0fc40fd"