mirror of
https://github.com/arnaucube/arbo.git
synced 2026-01-24 12:43:45 +01:00
Migrate kv db to go.vocdoni.io/dvote/db interface
Case tree empty, AddBatch was 10.95x times faster than without AddBatch nCPU: 4, nLeafs: 1024, hash: Poseidon, db: memory dbgStats(hash: 2.047k, dbGet: 1, dbPut: 2.049k) Case tree not empty w/ few leafs, AddBatch was 7.28x times faster than without AddBatch nCPU: 4, nLeafs: 1024, hash: Poseidon, db: memory dbgStats(hash: 2.047k, dbGet: 198, dbPut: 2.049k) Case tree not empty w/ enough leafs, AddBatch was 5.94x times faster than without AddBatch nCPU: 4, nLeafs: 1024, hash: Poseidon, db: memory dbgStats(hash: 2.047k, dbGet: 1.000k, dbPut: 2.049k) Case tree not empty, AddBatch was 9.27x times faster than without AddBatch nCPU: 4, nLeafs: 4096, hash: Poseidon, db: memory dbgStats(hash: 8.191k, dbGet: 1.800k, dbPut: 8.193k) Case tree not empty & unbalanced, AddBatch was 10.67x times faster than without AddBatch nCPU: 4, nLeafs: 4096, hash: Poseidon, db: memory dbgStats(hash: 10.409k, dbGet: 2.668k, dbPut: 10.861k) TestAddBatchBench: nCPU: 4, nLeafs: 50000, hash: Blake2b, db: badgerdb Add loop: 10.10829114s AddBatch: 732.030263ms dbgStats(hash: 122.518k, dbGet: 1, dbPut: 122.520k) TestDbgStats add in loop in emptyTree dbgStats(hash: 141.721k, dbGet: 134.596k, dbPut: 161.721k) addbatch caseEmptyTree dbgStats(hash: 24.402k, dbGet: 1, dbPut: 24.404k) addbatch caseNotEmptyTree dbgStats(hash: 26.868k, dbGet: 2.468k, dbPut: 26.872k)
This commit is contained in:
10
vt_test.go
10
vt_test.go
@@ -6,7 +6,7 @@ import (
|
||||
"testing"
|
||||
|
||||
qt "github.com/frankban/quicktest"
|
||||
"github.com/iden3/go-merkletree/db/memory"
|
||||
"go.vocdoni.io/dvote/db"
|
||||
)
|
||||
|
||||
func TestVirtualTreeTestVectors(t *testing.T) {
|
||||
@@ -76,7 +76,9 @@ func testVirtualTree(c *qt.C, maxLevels int, keys, values [][]byte) {
|
||||
c.Assert(len(keys), qt.Equals, len(values))
|
||||
|
||||
// normal tree, to have an expected root value
|
||||
tree, err := NewTree(memory.NewMemoryStorage(), maxLevels, HashFunctionSha256)
|
||||
database, err := db.NewBadgerDB(c.TempDir())
|
||||
c.Assert(err, qt.IsNil)
|
||||
tree, err := NewTree(database, maxLevels, HashFunctionSha256)
|
||||
c.Assert(err, qt.IsNil)
|
||||
for i := 0; i < len(keys); i++ {
|
||||
err := tree.Add(keys[i], values[i])
|
||||
@@ -113,7 +115,9 @@ func TestVirtualTreeAddBatch(t *testing.T) {
|
||||
}
|
||||
|
||||
// normal tree, to have an expected root value
|
||||
tree, err := NewTree(memory.NewMemoryStorage(), maxLevels, HashFunctionBlake2b)
|
||||
database, err := db.NewBadgerDB(c.TempDir())
|
||||
c.Assert(err, qt.IsNil)
|
||||
tree, err := NewTree(database, maxLevels, HashFunctionBlake2b)
|
||||
c.Assert(err, qt.IsNil)
|
||||
for i := 0; i < len(keys); i++ {
|
||||
err := tree.Add(keys[i], values[i])
|
||||
|
||||
Reference in New Issue
Block a user