mirror of
https://github.com/privacy-scaling-explorations/zk-kit.git
synced 2026-04-22 03:00:15 -04:00
refactor: update pkg name
This commit is contained in:
39
packages/incremental-merkle-tree/benchmarks/index.ts
Normal file
39
packages/incremental-merkle-tree/benchmarks/index.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import b from "benny"
|
||||
import { poseidon } from "circomlibjs"
|
||||
import { IncrementalMerkleTree } from "../src"
|
||||
import { IncrementalQuinTree } from "incrementalquintree"
|
||||
|
||||
const newTree = new IncrementalMerkleTree(poseidon, 20, BigInt(0), 2)
|
||||
const oldTree = new IncrementalQuinTree(20, BigInt(0), 2, poseidon)
|
||||
|
||||
const numberOfLeaves = 2 ** 4
|
||||
|
||||
b.suite(
|
||||
"Incremental Merkle tree benchmarks",
|
||||
|
||||
b.add("Generate proof for new tree", () => {
|
||||
for (let i = 0; i < numberOfLeaves; i += 1) {
|
||||
newTree.insert(BigInt(i + 1))
|
||||
}
|
||||
|
||||
for (let i = 0; i < numberOfLeaves; i += 1) {
|
||||
newTree.createProof(i)
|
||||
}
|
||||
}),
|
||||
|
||||
b.add("Generate proof for old tree", () => {
|
||||
for (let i = 0; i < numberOfLeaves; i += 1) {
|
||||
oldTree.insert(BigInt(i + 1))
|
||||
}
|
||||
|
||||
for (let i = 0; i < numberOfLeaves; i += 1) {
|
||||
oldTree.genMerklePath(i)
|
||||
}
|
||||
}),
|
||||
|
||||
b.cycle(),
|
||||
b.complete(),
|
||||
|
||||
b.save({ file: "reduce", version: "1.0.0", details: true }),
|
||||
b.save({ file: "reduce", format: "chart.html", details: true })
|
||||
)
|
||||
@@ -26,6 +26,7 @@
|
||||
},
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"benchmark": "node -r ts-node/register benchmarks/index.ts",
|
||||
"build:watch": "rollup -c rollup.config.ts -w --configPlugin typescript",
|
||||
"build": "rimraf dist && rollup -c rollup.config.ts --configPlugin typescript",
|
||||
"prepublishOnly": "yarn build"
|
||||
4
packages/incremental-merkle-tree/tsconfig.json
Normal file
4
packages/incremental-merkle-tree/tsconfig.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"include": ["src", "tests", "benchmarks", "rollup.config.ts"]
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
// const b = require("benny");
|
||||
// const { poseidon } = require("circomlibjs");
|
||||
// const { IncrementalMerkleTree } = require("../dist/types")
|
||||
// const Tree = require("incrementalquintree/build/IncrementalQuinTree")
|
||||
|
||||
// const tree = new IncrementalMerkleTree(poseidon, 20, BigInt(0), 2)
|
||||
// const old = new Tree.IncrementalQuinTree(20, BigInt(0), 2, poseidon)
|
||||
|
||||
// const numberOfLeaves = 2 ** 10;
|
||||
|
||||
// b.suite(
|
||||
// 'incremental merkle tree benchmarks',
|
||||
|
||||
// b.add('generate proof for nary binary tree', () => {
|
||||
// for (let i = 0; i < numberOfLeaves; i+=1) {
|
||||
// tree.insert(BigInt(i + 1))
|
||||
// }
|
||||
|
||||
// for (let i = 0; i < numberOfLeaves; i += 1) {
|
||||
// tree.createProof(i)
|
||||
// }
|
||||
// }),
|
||||
|
||||
// b.add('generate proof for old binary tree', () => {
|
||||
// for (let i = 0; i < numberOfLeaves; i+=1) {
|
||||
// old.insert(BigInt(i + 1))
|
||||
// }
|
||||
|
||||
// for (let i = 0; i < numberOfLeaves; i += 1) {
|
||||
// old.genMerklePath(i)
|
||||
// }
|
||||
// }),
|
||||
|
||||
// b.cycle(),
|
||||
// b.complete(),
|
||||
// b.save({ file: 'reduce', version: '1.0.0', details: true }),
|
||||
// b.save({ file: 'reduce', format: 'chart.html', details: true }),
|
||||
// )
|
||||
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"include": ["src", "tests", "rollup.config.ts", "benchmarks"]
|
||||
}
|
||||
Reference in New Issue
Block a user