Skip to content

Commit

Permalink
fix(benchmarks): added counter initialization mistake
Browse files Browse the repository at this point in the history
Changed to initialize from -1 instead of 0 to fix the logic to start from the first

samples element

re privacy-scaling-explorations#311
  • Loading branch information
0xarcano committed Sep 21, 2024
1 parent 93efa6b commit 1585210
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions benchmarks/benchmark-merkle-trees.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export default function run(treeDepth: number, numberOfLeaves: number) {
b.add(`SparseMT - Add ${numberOfLeaves} leaves`, () => {
try {
sparseMerkleTree2.add(leafSMT.toString(16), Math.floor(Math.random() * 10).toString())
leafSMT += 1
leafSMT += 1
} catch (error) {
logger.error(name)
logger.error(error)
Expand Down Expand Up @@ -132,7 +132,7 @@ export default function run(treeDepth: number, numberOfLeaves: number) {
if (leafIMT < samples) {
incrementalMerkleTree.createProof(sample[leafIMT])
} else {
leafIMT = 0
leafIMT = -1
}
leafIMT += 1
} catch (error) {
Expand All @@ -145,7 +145,7 @@ export default function run(treeDepth: number, numberOfLeaves: number) {
if (leafLeanIMT < samples) {
leanIncrementalMerkleTree.generateProof(sample[leafLeanIMT])
} else {
leafLeanIMT = 0
leafLeanIMT = -1
}
leafLeanIMT += 1
} catch (error) {
Expand All @@ -158,7 +158,7 @@ export default function run(treeDepth: number, numberOfLeaves: number) {
if (leafSMT < samples) {
sparseMerkleTree.createProof(sample[leafSMT].toString(16))
} else {
leafSMT = 0
leafSMT = -1
}
leafSMT += 1
} catch (error) {
Expand Down

0 comments on commit 1585210

Please sign in to comment.