Skip to content

Refactor to replace imurmurhash with node:crypto#9177

Merged
jeddy3 merged 1 commit into
mainfrom
issue-9173
Mar 26, 2026
Merged

Refactor to replace imurmurhash with node:crypto#9177
jeddy3 merged 1 commit into
mainfrom
issue-9173

Conversation

@ybiquitous

Copy link
Copy Markdown
Member

Which issue, if any, is this issue related to?

Closes #9173

Is there anything in the PR that needs further explanation?

Benchmark script (tmp/benchmark-hash.mjs)

import { performance } from 'node:perf_hooks';

import hash from '../lib/utils/hash.mjs';

function benchmark(fn, input, iterations) {
	// Warm-up
	for (let i = 0; i < 1000; i++) {
		fn(input);
	}

	const start = performance.now();
	for (let i = 0; i < iterations; i++) {
		fn(input);
	}
	const end = performance.now();

	return {
		timeInMs: end - start,
		opsPerSecond: Math.round(iterations / ((end - start) / 1000)),
	};
}

const input = process.env['INPUT'];

if (!input) throw new Error('INPUT is required');

const iterations = process.env['ITERATIONS'];

if (!iterations) throw new Error('ITERATIONS is required');

const { timeInMs, opsPerSecond } = benchmark(hash, input, iterations);

console.log('Time: %d ms', timeInMs);
console.log('Ops: %d / s', opsPerSecond);

Run:

INPUT=$(< system-tests/001/config.json) ITERATIONS=1000 node tmp/benchmark-hash.mjs

Results in 1000 iterations:

Before:

Time: 3.062415999999999 ms
Ops: 326540 / s

After:

Time: 3.935333 ms
Ops: 254108 / s

I believe the difference of around 1 ms will have a very minor impact.

@changeset-bot

changeset-bot Bot commented Mar 25, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 9bd86c2

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions

Copy link
Copy Markdown
Contributor

This PR is packaged and the instant preview is available (9bd86c2). View the demo website.

Install it locally:

npm i -D https://pkg.pr.new/stylelint@9bd86c2

@ybiquitous ybiquitous marked this pull request as ready for review March 25, 2026 13:17
@ybiquitous ybiquitous requested a review from a team as a code owner March 25, 2026 13:17

@jeddy3 jeddy3 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you.

@jeddy3 jeddy3 merged commit dd7231b into main Mar 26, 2026
20 checks passed
@jeddy3 jeddy3 deleted the issue-9173 branch March 26, 2026 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Refactor to replace imurmurhash with node:crypto

2 participants