generated from olivmath/template
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add: benchmark of proof, root and check proof functions
- Loading branch information
Showing
5 changed files
with
159 additions
and
1 deletion.
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
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,46 @@ | ||
# Perfomance Benchmark | ||
|
||
## Merkle Tree Proof | ||
|
||
| Name (time in us) | 10 leaves | 100 leaves | 1000 leaves | | ||
| ----------------- | ---------------- | ----------------- | ------------------- | | ||
| Min | 178.0987 (1.0) | 1,595.7355 (8.96) | 15,613.7943 (87.67) | | ||
| Max | 269.6514 (1.0) | 1,773.8342 (6.58) | 16,057.9681 (59.55) | | ||
| Mean | 187.1040 (1.0) | 1,617.6854 (8.65) | 15,705.7848 (83.94) | | ||
| StdDev | 5.8367 (1.0) | 16.4950 (2.83) | 64.8987 (11.12) | | ||
| Median | 185.9665 (1.0) | 1,612.1864 (8.67) | 15,699.8634 (84.42) | | ||
| IQR | 2.8610 (1.0) | 21.6961 (7.58) | 43.2134 (15.10) | | ||
| Outliers | 264;258 | 98;10 | 7;3 | | ||
| OPS | 5,344.6217 (1.0) | 618.1672 (0.12) | 63.6708 (0.01) | | ||
| Rounds | 2253 | 607 | 61 | | ||
| Iterations | 1 | 1 | 1 | | ||
|
||
## Merkle Tree Root | ||
|
||
| Name (time in us) | 10 leaves | 100 leaves | 1000 leaves | | ||
| ----------------- | ---------------- | ----------------- | ------------------- | | ||
| Min | 160.6941 (1.0) | 1,578.0926 (9.82) | 15,678.8826 (97.57) | | ||
| Max | 292.0628 (1.0) | 1,782.8941 (6.10) | 16,387.7010 (56.11) | | ||
| Mean | 164.7549 (1.0) | 1,597.4649 (9.70) | 15,759.9680 (95.66) | | ||
| StdDev | 7.0878 (1.0) | 15.8178 (2.23) | 98.7442 (13.93) | | ||
| Median | 163.0783 (1.0) | 1,595.2587 (9.78) | 15,733.5997 (96.48) | | ||
| IQR | 1.9073 (1.0) | 10.0136 (5.25) | 67.2340 (35.25) | | ||
| Outliers | 440;680 | 58;43 | 4;4 | | ||
| OPS | 6,069.6213 (1.0) | 625.9918 (0.10) | 63.4519 (0.01) | | ||
| Rounds | 5646 | 631 | 62 | | ||
| Iterations | 1 | 1 | 1 | | ||
|
||
## Merkle Tree Verify | ||
|
||
| Name (time in us) | 10 leaves | 100 leaves | 1000 leaves | | ||
| ----------------- | ---------------- | ----------------- | ------------------- | | ||
| Min | 300.8842 (1.0) | 2,418.9949 (8.04) | 23,648.9773 (78.60) | | ||
| Max | 392.9138 (1.0) | 2,607.8224 (6.64) | 24,820.0893 (63.17) | | ||
| Mean | 311.0095 (1.0) | 2,466.0162 (7.93) | 23,804.4375 (76.54) | | ||
| StdDev | 5.6751 (1.0) | 20.7209 (3.65) | 195.0959 (34.38) | | ||
| Median | 308.9905 (1.0) | 2,463.8176 (7.97) | 23,754.4775 (76.88) | | ||
| IQR | 2.8610 (1.0) | 21.4577 (7.50) | 76.0555 (26.58) | | ||
| Outliers | 240;239 | 61;15 | 4;4 | | ||
| OPS | 3,215.3358 (1.0) | 405.5123 (0.13) | 42.0090 (0.01) | | ||
| Rounds | 3040 | 388 | 42 | | ||
| Iterations | 1 | 1 | 1 | |
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,39 @@ | ||
from merkly.mtree import MerkleTree | ||
import pytest | ||
import time | ||
|
||
|
||
def create_proof_10_leaves(): | ||
leafs = [str(i) for i in range(10)] | ||
tree = MerkleTree(leafs) | ||
proof = tree.proof("5") | ||
assert len(proof) == 4 | ||
|
||
|
||
def create_proof_100_leaves(): | ||
leafs = [str(i) for i in range(100)] | ||
tree = MerkleTree(leafs) | ||
proof = tree.proof("50") | ||
assert len(proof) == 7 | ||
|
||
|
||
def create_proof_1000_leaves(): | ||
leafs = [str(i) for i in range(1000)] | ||
tree = MerkleTree(leafs) | ||
proof = tree.proof("500") | ||
assert len(proof) == 10 | ||
|
||
|
||
@pytest.mark.benchmark(group="MerkleTreeProof", timer=time.time) | ||
def test_create_proof_10_leaves(benchmark): | ||
benchmark(create_proof_10_leaves) | ||
|
||
|
||
@pytest.mark.benchmark(group="MerkleTreeProof", timer=time.time) | ||
def test_create_proof_100_leaves(benchmark): | ||
benchmark(create_proof_100_leaves) | ||
|
||
|
||
@pytest.mark.benchmark(group="MerkleTreeProof", timer=time.time) | ||
def test_create_proof_1000_leaves(benchmark): | ||
benchmark(create_proof_1000_leaves) |
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,39 @@ | ||
import time | ||
import pytest | ||
from merkly.mtree import MerkleTree | ||
|
||
|
||
def verify_proof_10_leaves(): | ||
leafs = [str(i) for i in range(10)] | ||
tree = MerkleTree(leafs) | ||
proof = tree.proof("0") | ||
assert tree.verify(proof, "0") | ||
|
||
|
||
def verify_proof_100_leaves(): | ||
leafs = [str(i) for i in range(100)] | ||
tree = MerkleTree(leafs) | ||
proof = tree.proof("0") | ||
assert tree.verify(proof, "0") | ||
|
||
|
||
def verify_proof_1000_leaves(): | ||
leafs = [str(i) for i in range(1000)] | ||
tree = MerkleTree(leafs) | ||
proof = tree.proof("0") | ||
assert tree.verify(proof, "0") | ||
|
||
|
||
@pytest.mark.benchmark(group="MerkleTreeVerify", timer=time.time) | ||
def test_verify_proof_10_leaves(benchmark): | ||
benchmark(verify_proof_10_leaves) | ||
|
||
|
||
@pytest.mark.benchmark(group="MerkleTreeVerify", timer=time.time) | ||
def test_verify_proof_100_leaves(benchmark): | ||
benchmark(verify_proof_100_leaves) | ||
|
||
|
||
@pytest.mark.benchmark(group="MerkleTreeVerify", timer=time.time) | ||
def test_verify_proof_1000_leaves(benchmark): | ||
benchmark(verify_proof_1000_leaves) |
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,34 @@ | ||
from merkly.mtree import MerkleTree | ||
import pytest | ||
import time | ||
|
||
|
||
def create_merkle_tree_root_10_leaves(): | ||
leafs = [str(i) for i in range(10)] | ||
tree = MerkleTree(leafs) | ||
assert tree.root == "f8b45f3031274577651c6d43e7ec3f7361e82b2295e24a9b369693354d3a2db8" | ||
|
||
|
||
def create_merkle_tree_root_100_leaves(): | ||
leafs = [str(i) for i in range(100)] | ||
tree = MerkleTree(leafs) | ||
assert tree.root == "8e92f7efa075e532b920ef39adb04a0147ac84d99315584dbd2a1cb868019c35" | ||
|
||
|
||
def create_merkle_tree_root_1000_leaves(): | ||
leafs = [str(i) for i in range(1000)] | ||
tree = MerkleTree(leafs) | ||
assert tree.root == "e66024476f6ef8f431f07dca6ea0d10dd904dda4b47488a49e75f8671ba733ee" | ||
|
||
|
||
@pytest.mark.benchmark(group="MerkleTreeRoot", timer=time.time) | ||
def test_create_merkle_tree_root_10_leaves(benchmark): | ||
benchmark(create_merkle_tree_root_10_leaves) | ||
|
||
@pytest.mark.benchmark(group="MerkleTreeRoot", timer=time.time) | ||
def test_create_merkle_tree_root_100_leaves(benchmark): | ||
benchmark(create_merkle_tree_root_100_leaves) | ||
|
||
@pytest.mark.benchmark(group="MerkleTreeRoot", timer=time.time) | ||
def test_create_merkle_tree_root_1000_leaves(benchmark): | ||
benchmark(create_merkle_tree_root_1000_leaves) |