GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — benchmark: merge crc32c into crc32 zlib benchmark by trivikr · Pull Request #67004 · nodejs/node

benchmark: merge crc32c into crc32 zlib benchmark #67004

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.

Sign up for GitHub

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

Merged
nodejs-github-bot merged 1 commit into nodejs:main from trivikr:zlib-crc32-benchmark
Nov 1, 2026

Uh oh!

There was an error while loading. Please reload this page.

Merged

benchmark: merge crc32c into crc32 zlib benchmark #67004

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
1 commit
Select commit
35acaa8
benchmark: merge crc32c into crc32 zlib benchmark
trivikr Oct 25, 2026
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

There are no files selected for viewing

15 changes: 9 additions & 6 deletions 15 benchmark/zlib/crc32.js
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
'use strict';

const common = require('../common.js');
const { crc32 } = require('zlib');
const zlib = require('zlib');

// Benchmark crc32 on Buffer and String inputs across sizes.
// Benchmark crc32 and crc32c on Buffer and String inputs across sizes.
// Iteration count is scaled inversely with input length to keep runtime sane.
// Example:
// node benchmark/zlib/crc32.js type=buffer len=4096 n=4000000
// node benchmark/zlib/crc32.js algorithm=crc32c type=buffer len=4096 n=4000000
// ./out/Release/node benchmark/zlib/crc32.js --test

const bench = common.createBenchmark(main, {
algorithm: ['crc32', 'crc32c'],
type: ['buffer', 'string'],
len: [32, 256, 4096, 65536],
n: [4e6],
Expand All @@ -28,19 +29,21 @@ function makeAsciiString(size) {
return out;
}

function main({ type, len, n }) {
function main({ algorithm, type, len, n }) {
const crc = zlib[algorithm];

// Scale iterations so that total processed bytes roughly constant around n*4096 bytes.
const scale = 4096 / len;
const iters = Math.max(1, Math.floor(n * scale));

const data = type === 'buffer' ? makeBuffer(len) : makeAsciiString(len);

let acc = 0;
for (let i = 0; i < Math.min(iters, 10000); i++) acc ^= crc32(data, 0);
for (let i = 0; i < Math.min(iters, 10000); i++) acc ^= crc(data, 0);

bench.start();
let sum = 0;
for (let i = 0; i < iters; i++) sum ^= crc32(data, 0);
for (let i = 0; i < iters; i++) sum ^= crc(data, 0);
bench.end(iters);

if (sum === acc - 1) process.stderr.write('');
Expand Down
47 changes: 0 additions & 47 deletions 47 benchmark/zlib/crc32c.js
Show comments
View file
Open in desktop

This file was deleted.

Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.