sse4_crc32
Advanced tools
Comparing version 5.4.0 to 6.0.0
@@ -13,3 +13,3 @@ { | ||
], | ||
"version": "5.4.0", | ||
"version": "6.0.0", | ||
"author": "Anand Suresh <anandsuresh@gmail.com> (https://github.com/anandsuresh)", | ||
@@ -25,20 +25,20 @@ "license": "MIT", | ||
"engines": { | ||
"node": ">=5.10.0" | ||
"node": ">=4" | ||
}, | ||
"main": "./sse4_crc32", | ||
"dependencies": { | ||
"bindings": "~1.5.0", | ||
"nan": "2.14.0" | ||
"bindings": "^1.3.0", | ||
"node-addon-api": "^1.3.0" | ||
}, | ||
"devDependencies": { | ||
"chai": "^2.0.0", | ||
"crc32": "^0.2.1", | ||
"mocha": "^2.1.0", | ||
"chai": "^4.2.0", | ||
"crc32": "^0.2.2", | ||
"mocha": "^6.2.0", | ||
"node-gyp": "^5.0.3" | ||
}, | ||
"scripts": { | ||
"benchmark": "node benchmark", | ||
"test": "mocha test/*test.js", | ||
"debug": "echo \"platform: $(uname -a)\"; echo \"node.js: $(node -v)\"; echo \"npm: $(npm -v)\"; echo \"node-gyp: $(./node_modules/.bin/node-gyp -v)\"; node -e \"console.log('H/w CRC Support: ' + require('./sse4_crc32').isHardwareCrcSupported());\"; node -pe \"require('./sse4_crc32');\"", | ||
"hwcrc": "node -e \"console.log('H/w CRC Support: ' + require('./sse4_crc32').isHardwareCrcSupported());\"" | ||
"debug": "echo \"platform: $(uname -a)\"; echo \"node.js: $(node -v)\"; echo \"npm: $(npm -v)\"; echo \"node-gyp: $(./node_modules/.bin/node-gyp -v)\"; node -e \"console.log('H/w CRC Support: ' + require('.').hardware_support);\"; node -pe \"require('.');\"", | ||
"hwcrc": "node -e \"console.log('H/w CRC Support: ' + require('.').hardware_support);\"" | ||
} | ||
} |
120
README.md
@@ -1,91 +0,91 @@ | ||
# SSE4-CRC32 [![Build Status](https://travis-ci.org/anandsuresh/sse4_crc32.svg?branch=master)](https://travis-ci.org/anandsuresh/sse4_crc32) [![npm version](https://badge.fury.io/js/sse4_crc32.svg)](http://badge.fury.io/js/sse4_crc32) | ||
# sse4-crc32 | ||
Starting with the Nehalam series, Intel processors feature the Streaming SIMD Extensions instruction set which | ||
provide a hardware-accelerated version of the CRC32 algorithm (Castagnoli variant). This library uses the | ||
Intel SSE 4.2 instruction set to provide a fast CRC-32 algorithm. | ||
[![node (scoped)](https://img.shields.io/node/v/sse4_crc32.svg?style=plastic)](https://nodejs.org/en/download/) | ||
[![npm (scoped)](https://img.shields.io/npm/v/sse4_crc32.svg?style=plastic)](https://www.npmjs.com/package/sse4_crc32) | ||
[![npm](https://img.shields.io/npm/dt/sse4_crc32.svg?style=plastic)](https://www.npmjs.com/package/sse4_crc32) | ||
[![Travis](https://img.shields.io/travis/anandsuresh/sse4_crc32.svg?style=plastic)](https://travis-ci.org/anandsuresh/sse4_crc32) | ||
[![license](https://img.shields.io/github/license/anandsuresh/sse4_crc32.svg?style=plastic)](LICENSE) | ||
[![GitHub followers](https://img.shields.io/github/followers/anandsuresh.svg?style=social&label=Follow)](https://github.com/anandsuresh) | ||
[![Twitter Follow](https://img.shields.io/twitter/follow/anandsuresh.svg?style=social&label=Follow)](https://twitter.com/intent/follow?screen_name=anandsuresh) | ||
Starting with the Nehalam series, Intel processors feature the Streaming SIMD Extensions instruction set which provide a hardware-accelerated version of the CRC-32 algorithm (Castagnoli variant). This library uses the Intel SSE 4.2 instruction set to provide a fast CRC-32C implementation. | ||
## Features | ||
## features | ||
- Intel Streaming SIMD Extensions 4.2 based hardware accelerated CRC-32C calculation | ||
- Graceful fallback to software-based CRC (table-based CRC calculation) | ||
- Progressive CRC-32C calculation | ||
- Supports Node.js buffers | ||
- Intel Streaming SIMD Extensions 4.2 based hardware-accelerated CRC-32C calculation | ||
- Graceful fallback to software-based CRC-32C (table-based CRC calculation) | ||
- Supports streams, strings and buffers | ||
## performance | ||
## Performance | ||
The tests were run on a Macbook Air running an Intel Core i7 processor, with 16GB of RAM and used buffers instead of strings to prevent having items on the V8 heap that might cause the garbage collector to fire frequently and interfere with the test run-times. | ||
The tests were run on a Macbook Air running an Intel Core i7 processor, with 8GB of RAM and used buffers | ||
instead of strings to prevent having items on the V8 heap that might cause the garbage collector to fire | ||
frequently and interfere with the test run-times. | ||
Below are the results from the 2 test cases: | ||
> node benchmark/1.single_1kb_length_buffer.benchmark.js | ||
100000 calls to calculate CRC on a 1024 byte buffer... | ||
Hardware-based CRC-32C: 27.388368 ms | ||
Software-based CRC-32C: 87.832587 ms | ||
Pure JS CRC-32C (table-based): 726.95698 ms | ||
Pure JS CRC-32C (direct): 4332.993692 ms | ||
``` bash | ||
> node benchmark | ||
> node benchmark/2.multi_random_length_buffer.benchmark.js | ||
100000 calls to calculate CRC on random-length buffers upto 4096 bytes long... | ||
Avg. buffer length: 2049 bytes | ||
Hardware-based CRC-32C: 88.440507 ms | ||
Software-based CRC-32C: 173.136638 ms | ||
Pure JS CRC-32C (table-based): 2131.861339 ms | ||
Pure JS CRC-32C (direct): 9006.901272 ms | ||
single fixed-size buffer, 10000 iterations: | ||
- Native SSE 4.2 CRC-32C: 4.319142 ms | ||
- Native Table-based CRC-32C: 10.726345 ms | ||
- JavaScript (table-based) CRC-32C: 60.704765 ms | ||
- JavaScript (direct) CRC-32C: 336.376904 ms | ||
## Installation | ||
multiple random-length buffers, 10000 iterations: | ||
- Native SSE 4.2 CRC-32C: 60.194043 ms | ||
- Native Table-based CRC-32C: 225.459861 ms | ||
- JavaScript (table-based) CRC-32C: 1786.079168 ms | ||
- JavaScript (direct) CRC-32C: 12307.033387 ms | ||
``` | ||
## installation | ||
Use the following command to install the library from npm: | ||
npm install sse4_crc32 | ||
``` bash | ||
npm install --save sse4_crc32 | ||
``` | ||
## usage | ||
## Usage | ||
Import the module: | ||
Using the library is quite simple. Start out by including the library in your code: | ||
``` javascript | ||
const Sse4Crc32 = require("sse4_crc32") | ||
``` | ||
var Sse4Crc32 = require("sse4_crc32"); | ||
Calculate the 32-bit CRC for any string: | ||
To calculate the 32-bit CRC for any string, simply use the following code: | ||
``` javascript | ||
const crc = Sse4Crc32.calculate("my string") | ||
``` | ||
var crc = Sse4Crc32.calculate("my string"); | ||
Instead of passing in a string, a buffer can be passed to the `calculate()` function. Furthermore, the `calculate()` function takes an optional `initialCrc` value as the second argument, allowing for progressive CRC calculation. | ||
Instead of passing in a string, a buffer can be passed to the `calculate()` function. | ||
``` javascript | ||
const crc = Sse4Crc32.calculate("my string") | ||
const newCrc = Sse4Crc32.calculate("my new string", crc) | ||
``` | ||
Furthermore, the `calculate()` function takes an optional `initialCrc` value as the second argument, allowing | ||
for progressive CRC calculation. | ||
You can also calculate the CRC for streams, as follows: | ||
var crc = Sse4Crc32.calculate("my string"); | ||
var newCrc = Sse4Crc32.calculate("my new string", crc); | ||
``` javascript | ||
const stream = Sse4Crc32 | ||
.fromStream(fs.createReadStream('/path/to/file')) | ||
.on('finish', () => console.log(`CRC-32C: ${stream.crc}`)) | ||
``` | ||
Another way to calculate CRC in a progressive manner is as follows: | ||
## how to compile | ||
var sse4crc32 = new Sse4Crc32.CRC32(); | ||
var myInputs = [ "some string", new Buffer("a buffer"), "yet another string", new Buffer("yet another buffer") ]; | ||
var crc; | ||
myInputs.forEach(function (string) { | ||
sse4crc32.update(string); | ||
}); | ||
crc = sse4crc32.crc(); | ||
Also see the example code in the [examples](https://github.com/anandsuresh/sse4_crc32/tree/master/examples) | ||
directory. | ||
## How to compile | ||
Once the repository has been cloned, use one of the following commands to build the library: | ||
make all // Builds the release version of the library and runs all tests | ||
make debug // Builds the debug version of the library | ||
make clean // Removes all files generated by builds | ||
``` bash | ||
make all // Builds the release version of the library and runs all tests | ||
make debug // Builds the debug version of the library | ||
make clean // Removes all files generated by builds | ||
``` | ||
## contact | ||
## Contact | ||
All feedback/suggestions/criticisms can be directed to [Anand Suresh](http://www.github.com/anandsuresh) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
93772
19
237
1
2
+ Addednode-addon-api@^1.3.0
+ Addednode-addon-api@1.7.2(transitive)
- Removednan@2.14.0
- Removednan@2.14.0(transitive)
Updatedbindings@^1.3.0