This repository has been archived by the owner on Feb 27, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve treeHasher performance (#42)
By doing two things: - Pre-allocated enough size for slice, instead of initializing a small one then continuously appending to it. - Initializing placeholder slice once instead of creating new one everytime treeHasher.placeholder is called. That helps improves the sppeed, and less allocations for Update/Delete operations: name old time/op new time/op delta SparseMerkleTree_Update-8 11.9µs ± 3% 11.2µs ± 3% -5.89% (p=0.008 n=5+5) SparseMerkleTree_Delete-8 9.66µs ± 2% 5.40µs ± 2% -44.12% (p=0.008 n=5+5) name old alloc/op new alloc/op delta SparseMerkleTree_Update-8 17.7kB ± 0% 16.1kB ± 1% -9.42% (p=0.016 n=4+5) SparseMerkleTree_Delete-8 16.3kB ± 0% 13.9kB ± 0% -14.82% (p=0.008 n=5+5) name old allocs/op new allocs/op delta SparseMerkleTree_Update-8 117 ± 0% 63 ± 0% -46.15% (p=0.029 n=4+4) SparseMerkleTree_Delete-8 94.4 ± 1% 28.6 ± 2% -69.70% (p=0.008 n=5+5)
- Loading branch information