npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

sse4_crc32

v7.0.0

Published

Hardware-accelerated CRC-32C with software fallback

Downloads

181,876

Readme

sse4-crc32

node (scoped) npm (scoped) npm Travis license GitHub followers Twitter Follow

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

  • 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

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.

Below are the results from the 2 test cases:

> node benchmark

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


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 --save sse4_crc32

usage

Import the module:

const Sse4Crc32 = require("sse4_crc32")

Calculate the 32-bit CRC for any string:

const 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.

const crc = Sse4Crc32.calculate("my string")
const newCrc = Sse4Crc32.calculate("my new string", crc)

You can also calculate the CRC for streams, as follows:

const stream = Sse4Crc32
  .fromStream(fs.createReadStream('/path/to/file'))
  .on('finish', () => console.log(`CRC-32C: ${stream.crc}`))

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

contact

All feedback/suggestions/criticisms can be directed to Anand Suresh