Skip to content

Commit

Permalink
Use rocksdb when testing
Browse files Browse the repository at this point in the history
  • Loading branch information
gdiazlo committed Mar 14, 2019
1 parent 3a4d0ee commit 08ffccf
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 7 deletions.
54 changes: 49 additions & 5 deletions balloon/balloon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ func TestConsistencyProofVerify(t *testing.T) {
func TestAddQueryAndVerify(t *testing.T) {
log.SetLogger("TestCacheWarmingUp", log.SILENT)

store, closeF := storage_utils.OpenBadgerStore(t, "/var/tmp/balloon.test.1")
store, closeF := storage_utils.OpenRocksDBStore(t, "/var/tmp/balloon.test.1")
defer closeF()

// start balloon
Expand All @@ -212,7 +212,7 @@ func TestCacheWarmingUp(t *testing.T) {

log.SetLogger("TestCacheWarmingUp", log.SILENT)

store, closeF := storage_utils.OpenBadgerStore(t, "/var/tmp/ballon_test.db")
store, closeF := storage_utils.OpenRocksDBStore(t, "/var/tmp/ballon_test.db")
defer closeF()

// start balloon
Expand Down Expand Up @@ -248,7 +248,7 @@ func TestCacheWarmingUp(t *testing.T) {
func TestTamperAndVerify(t *testing.T) {
log.SetLogger("TestTamperAndVerify", log.SILENT)

store, closeF := storage_utils.OpenBadgerStore(t, "/var/tmp/balloon.test.2")
store, closeF := storage_utils.OpenRocksDBStore(t, "/var/tmp/balloon.test.2")
defer closeF()

b, err := NewBalloon(store, hashing.NewSha256Hasher)
Expand Down Expand Up @@ -286,7 +286,7 @@ func TestTamperAndVerify(t *testing.T) {
func TestDeleteAndVerify(t *testing.T) {
log.SetLogger("TestDeleteAndVerify", log.SILENT)

store, closeF := storage_utils.OpenBadgerStore(t, "/var/tmp/balloon.test.3")
store, closeF := storage_utils.OpenRocksDBStore(t, "/var/tmp/balloon.test.3")
defer closeF()

b, err := NewBalloon(store, hashing.NewSha256Hasher)
Expand Down Expand Up @@ -316,7 +316,7 @@ func TestDeleteAndVerify(t *testing.T) {
func TestGenIncrementalAndVerify(t *testing.T) {
log.SetLogger("TestDeleteAndVerify", log.SILENT)

store, closeF := storage_utils.OpenBadgerStore(t, "/var/tmp/balloon.test.3")
store, closeF := storage_utils.OpenRocksDBStore(t, "/var/tmp/balloon.test.3")
defer closeF()

b, err := NewBalloon(store, hashing.NewSha256Hasher)
Expand Down Expand Up @@ -384,3 +384,47 @@ func BenchmarkQueryBadger(b *testing.B) {
}

}
func BenchmarkAddRocksDB(b *testing.B) {

log.SetLogger("BenchmarkAddRocksDB", log.SILENT)

store, closeF := storage_utils.OpenRocksDBStore(b, "/var/tmp/balloon_bench.db")
defer closeF()

balloon, err := NewBalloon(store, hashing.NewSha256Hasher)
require.NoError(b, err)

b.ResetTimer()
b.N = 100000
for i := 0; i < b.N; i++ {
event := rand.Bytes(128)
_, mutations, _ := balloon.Add(event)
store.Mutate(mutations)
}

}

func BenchmarkQueryRocksDB(b *testing.B) {
var events [][]byte
log.SetLogger("BenchmarkQueryRocksDB", log.SILENT)

store, closeF := storage_utils.OpenRocksDBStore(b, "/var/tmp/ballon_bench.db")
defer closeF()

balloon, err := NewBalloon(store, hashing.NewSha256Hasher)
require.NoError(b, err)

b.N = 100000
for i := 0; i < b.N; i++ {
event := rand.Bytes(128)
events = append(events, event)
_, mutations, _ := balloon.Add(event)
store.Mutate(mutations)
}

b.ResetTimer()
for i, e := range events {
balloon.QueryMembership(e, uint64(i))
}

}
2 changes: 1 addition & 1 deletion balloon/history/tree_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ func BenchmarkAdd(b *testing.B) {

log.SetLogger("BenchmarkAdd", log.SILENT)

store, closeF := storage_utils.OpenBadgerStore(b, "/var/tmp/history_tree_test.db")
store, closeF := storage_utils.OpenRocksDBStore(b, "/var/tmp/history_tree_test.db")
defer closeF()

tree := NewHistoryTree(hashing.NewSha256Hasher, store, 300)
Expand Down
2 changes: 1 addition & 1 deletion balloon/hyper/tree_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ func BenchmarkAdd(b *testing.B) {

log.SetLogger("BenchmarkAdd", log.SILENT)

store, closeF := storage_utils.OpenBadgerStore(b, "/var/tmp/hyper_tree_test.db")
store, closeF := storage_utils.OpenRocksDBStore(b, "/var/tmp/hyper_tree_test.db")
defer closeF()

hasher := hashing.NewSha256Hasher()
Expand Down

0 comments on commit 08ffccf

Please sign in to comment.