-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from ChainSafe/mkeil/perf-unit-test-with-mocha
feat: implement unit and perf tests with Mocha using CommonJS
- Loading branch information
Showing
14 changed files
with
1,039 additions
and
1,819 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Mocha opts | ||
extension: ["ts"] | ||
colors: true | ||
node-option: | ||
- "loader=ts-node/register" | ||
|
||
# benchmark opts | ||
threshold: 3 | ||
maxMs: 60_000 | ||
minRuns: 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
colors: true | ||
require: ts-node/register | ||
exit: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import {itBench} from "@dapplion/benchmark"; | ||
import {unshuffleList, SHUFFLE_ROUNDS_MINIMAL, asyncUnshuffleList} from "../../index"; | ||
import * as referenceImplementation from "../referenceImplementation"; | ||
|
||
// Lightouse Lodestar | ||
// 512 254.04 us 1.6034 ms (x6) | ||
// 16384 6.2046 ms 18.272 ms (x3) | ||
// 4000000 1.5617 s 4.9690 s (x3) | ||
|
||
for (const listSize of [ | ||
16384, 250_000, 1_000_000, | ||
// Don't run 4_000_000 since it's very slow and not testnet has gotten there yet | ||
// 4e6, | ||
]) { | ||
describe(`shuffle list - ${listSize} indices`, () => { | ||
const seed = Buffer.alloc(32, 0xac); | ||
const input: number[] = []; | ||
for (let i = 0; i < listSize; i++) input[i] = i; | ||
const indices = new Uint32Array(input); | ||
|
||
itBench<Uint32Array, Uint32Array>({ | ||
id: `JS - unshuffleList - ${listSize} indices`, | ||
fn: () => { | ||
referenceImplementation.unshuffleList(indices, seed, SHUFFLE_ROUNDS_MINIMAL); | ||
}, | ||
}); | ||
|
||
itBench<Uint32Array, Uint32Array>({ | ||
id: `Rust - unshuffleList - ${listSize} indices`, | ||
fn: () => { | ||
unshuffleList(indices, seed, SHUFFLE_ROUNDS_MINIMAL); | ||
}, | ||
}); | ||
|
||
itBench<Uint32Array, Uint32Array>({ | ||
id: `Rust - asyncUnshuffleList - ${listSize} indices`, | ||
fn: async () => { | ||
await asyncUnshuffleList(indices, seed, SHUFFLE_ROUNDS_MINIMAL); | ||
}, | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.