Skip to content

Commit

Permalink
update benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
ovx committed Apr 6, 2024
1 parent 74b0664 commit 55fb530
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 14 deletions.
29 changes: 24 additions & 5 deletions benchmark/bench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,18 @@ const challenge2 = await createChallenge({
});

const challenge3 = await createChallenge({
hmacKey,
maxNumber: 50000,
number: 50000,
});

const challenge4 = await createChallenge({
hmacKey,
maxNumber: 100000,
number: 100000,
});

const challenge4 = await createChallenge({
const challenge5 = await createChallenge({
hmacKey,
maxNumber: 500000,
number: 500000,
Expand All @@ -41,12 +47,15 @@ await benchmark('solveChallenge()', (bench) => {
.add('n = 10,000', async () => {
await solveChallenge(challenge2.challenge, challenge2.salt).promise;
})
.add('n = 100,000', async () => {
.add('n = 50,000', async () => {
await solveChallenge(challenge3.challenge, challenge3.salt).promise;
})
.add('n = 500,000', async () => {
.add('n = 100,000', async () => {
await solveChallenge(challenge4.challenge, challenge4.salt).promise;
})
.add('n = 500,000', async () => {
await solveChallenge(challenge5.challenge, challenge5.salt).promise;
})
});

await benchmark(`solveChallengeWorkers() (${workers} workers)`, (bench) => {
Expand All @@ -71,7 +80,7 @@ await benchmark(`solveChallengeWorkers() (${workers} workers)`, (bench) => {
challenge2.max,
);
})
.add('n = 100,000', async () => {
.add('n = 50,000', async () => {
await solveChallengeWorkers(
workerScript,
workers,
Expand All @@ -81,7 +90,7 @@ await benchmark(`solveChallengeWorkers() (${workers} workers)`, (bench) => {
challenge3.max,
);
})
.add('n = 500,000', async () => {
.add('n = 100,000', async () => {
await solveChallengeWorkers(
workerScript,
workers,
Expand All @@ -90,5 +99,15 @@ await benchmark(`solveChallengeWorkers() (${workers} workers)`, (bench) => {
challenge4.algorithm,
challenge4.max,
);
})
.add('n = 500,000', async () => {
await solveChallengeWorkers(
workerScript,
workers,
challenge5.challenge,
challenge5.salt,
challenge5.algorithm,
challenge5.max,
);
});
});
20 changes: 11 additions & 9 deletions deno_dist/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ALTCHA JS Library is a lightweight, zero-dependency library designed for creatin

## Compatibility

This library utilizes [Web Crypto](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto) and is intended for server-side use.
This library utilizes [Web Crypto](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto) and can be used in modern browsers and supported server environments:

- Node.js 16+
- Bun 1+
Expand Down Expand Up @@ -103,16 +103,18 @@ const solution = await solveChallengeWorkers(

```
> solveChallenge()
- n = 1,000............................... 317 ops/s ±2.63%
- n = 10,000.............................. 32 ops/s ±1.88%
- n = 100,000............................. 3 ops/s ±0.34%
- n = 500,000............................. 0 ops/s ±0.32%
- n = 1,000............................... 319 ops/s ±2.04%
- n = 10,000.............................. 31 ops/s ±1.02%
- n = 50,000.............................. 6 ops/s ±1.48%
- n = 100,000............................. 3 ops/s ±0.27%
- n = 500,000............................. 0 ops/s ±0.36%
> solveChallengeWorkers() (8 workers)
- n = 1,000............................... 66 ops/s ±3.44%
- n = 10,000.............................. 31 ops/s ±4.28%
- n = 100,000............................. 7 ops/s ±4.40%
- n = 500,000............................. 1 ops/s ±2.49%
- n = 1,000............................... 62 ops/s ±5.69%
- n = 10,000.............................. 30 ops/s ±4.35%
- n = 50,000.............................. 12 ops/s ±2.89%
- n = 100,000............................. 7 ops/s ±2.33%
- n = 500,000............................. 1 ops/s ±2.22%
```

Run with Bun on MacBook Pro M3-Pro. See [/benchmark](/benchmark/) folder for more details.
Expand Down

0 comments on commit 55fb530

Please sign in to comment.