-
Notifications
You must be signed in to change notification settings - Fork 85
/
storage_benchmark_test.go
48 lines (43 loc) · 1.15 KB
/
storage_benchmark_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
package tstorage
import (
"testing"
"github.com/stretchr/testify/require"
)
func BenchmarkStorage_InsertRows(b *testing.B) {
storage, err := NewStorage()
require.NoError(b, err)
b.ResetTimer()
for i := 1; i < b.N; i++ {
storage.InsertRows([]Row{
{Metric: "metric1", DataPoint: DataPoint{Timestamp: int64(i), Value: 0.1}},
})
}
}
// Select data points among a thousand data in memory
func BenchmarkStorage_SelectAmongThousandPoints(b *testing.B) {
storage, err := NewStorage()
require.NoError(b, err)
for i := 1; i < 1000; i++ {
storage.InsertRows([]Row{
{Metric: "metric1", DataPoint: DataPoint{Timestamp: int64(i), Value: 0.1}},
})
}
b.ResetTimer()
for i := 1; i < b.N; i++ {
_, _ = storage.Select("metric1", nil, 10, 100)
}
}
// Select data points among a million data in memory
func BenchmarkStorage_SelectAmongMillionPoints(b *testing.B) {
storage, err := NewStorage()
require.NoError(b, err)
for i := 1; i < 1000000; i++ {
storage.InsertRows([]Row{
{Metric: "metric1", DataPoint: DataPoint{Timestamp: int64(i), Value: 0.1}},
})
}
b.ResetTimer()
for i := 1; i < b.N; i++ {
_, _ = storage.Select("metric1", nil, 10, 100)
}
}