Skip to content

Commit 7f20519

Browse files
committed
test: Add performance test
--story=1
1 parent aa7b3bd commit 7f20519

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

performance_test.go

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,16 @@ func BenchmarkLeveldb_Get(b *testing.B) {
8787
db.Get([]byte(fmt.Sprintf("key-%03d", i)), nil)
8888
}
8989
}
90+
func TestCompareDbPerformance(t *testing.T) {
91+
sizes := []int{100, 200, 500, 1024, 10240}
92+
for _, size := range sizes {
93+
valueLength = size
94+
TestLeveldbPerformance(t)
95+
TestShardingDbPerformance(t)
96+
TestSharding6DbPerformance(t)
97+
TestShardingDbEncryptPerformance(t)
98+
}
99+
}
90100

91101
func TestShardingDbPerformance(t *testing.T) {
92102
pathList := []string{"/data/leveldb", "/data1/leveldb", getTempDir()}
@@ -107,8 +117,26 @@ func TestShardingDbPerformance(t *testing.T) {
107117
}
108118
}
109119

120+
func TestSharding6DbPerformance(t *testing.T) {
121+
pathList := []string{"/data/leveldb", "/data1/leveldb", "/data/leveldb1", "/data1/leveldb1", getTempDir(), getTempDir()}
122+
//remove all folder
123+
for _, path := range pathList {
124+
os.RemoveAll(path)
125+
}
126+
fmt.Printf("ShardingDb path[%v]", pathList)
127+
//Test shardingdb performance
128+
db, _ := OpenFile(pathList, nil)
129+
testDbPerformance(t, db, "shardingdb")
130+
db.Close()
131+
132+
//Print every folder size
133+
for _, path := range pathList {
134+
size, _ := folderSize(path)
135+
fmt.Printf("Folder[%s] size:%d\n", path, size)
136+
}
137+
}
110138
func TestShardingDbEncryptPerformance(t *testing.T) {
111-
pathList := []string{getTempDir(), getTempDir(), getTempDir(), getTempDir()}
139+
pathList := []string{"/data/leveldb", "/data1/leveldb", getTempDir()}
112140
var err error
113141
dbs := make([]LevelDbHandle, len(pathList))
114142
for i := 0; i < len(pathList); i++ {
@@ -149,8 +177,8 @@ func TestLeveldbPerformance(t *testing.T) {
149177
}
150178

151179
func testDbPerformance(t *testing.T, db CommonDbHandle, testName string) {
152-
fmt.Printf("start db performance test,batch[%d] thread[%d] loop[%d],record count:%d\n",
153-
batchSize, thread, loop, batchSize*thread*loop)
180+
fmt.Printf("start db performance test,batch[%d] thread[%d] loop[%d],record count:%d,value size:%d\n",
181+
batchSize, thread, loop, batchSize*thread*loop, valueLength)
154182
wg := sync.WaitGroup{}
155183
wg.Add(thread)
156184
start := time.Now()

0 commit comments

Comments
 (0)