-
Notifications
You must be signed in to change notification settings - Fork 0
/
storage_test.go
54 lines (47 loc) · 1.4 KB
/
storage_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Copyright (c) 2019 Meng Huang ([email protected])
// This package is licensed under a MIT license that can be found in the LICENSE file.
package raft
import (
"os"
"testing"
)
func TestStorageSafeOverWrite10B(t *testing.T) {
b := []byte("123456789\n")
storage := newStorage(defaultDataDir)
defer os.RemoveAll(defaultDataDir)
err := storage.SafeOverWrite("TestStorageSafeOverWrite10B", b)
if err != nil {
t.Error(err)
}
}
func BenchmarkStorageSafeOverWrite10B(t *testing.B) {
b := []byte("123456789\n")
storage := newStorage(defaultDataDir)
defer os.RemoveAll(defaultDataDir)
t.ResetTimer()
for i := 0; i < t.N; i++ {
storage.SafeOverWrite("BenchmarkStorageSafeOverWrite10B", b)
}
}
func BenchmarkStorageOverWrite10B(t *testing.B) {
b := []byte("123456789\n")
storage := newStorage(defaultDataDir)
defer os.RemoveAll(defaultDataDir)
t.ResetTimer()
for i := 0; i < t.N; i++ {
storage.OverWrite("BenchmarkStorageOverWrite10B", b)
}
}
func BenchmarkStorageSeekWrite10B(t *testing.B) {
b := []byte("123456789\n")
storage := newStorage(defaultDataDir)
defer os.RemoveAll(defaultDataDir)
storage.SeekWrite("BenchmarkStorageSeekWrite10B", 10, b)
storage.SeekWrite("BenchmarkStorageSeekWrite10B", 20, b)
storage.SeekWrite("BenchmarkStorageSeekWrite10B", 30, b)
b = []byte("000000000\n")
t.ResetTimer()
for i := 0; i < t.N; i++ {
storage.SeekWrite("BenchmarkStorageSeekWrite10B", 10, b)
}
}