Last active
November 4, 2016 00:23
-
-
Save jwilder/e1260ac5fec90e97ffa67710eb4a356f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func BenchmarkWAL_Write_1(b *testing.B) { | |
benchmarkWALWrite(b, 1) | |
} | |
// func BenchmarkWAL_Write_10(b *testing.B) { | |
// benchmarkWALWrite(b, 10) | |
// } | |
func benchmarkWALWrite(b *testing.B, concurrency int) { | |
points := map[string][]tsm1.Value{} | |
for i := 0; i < 1; i++ { | |
k := "cpu,host=A#!~#value" | |
points[k] = append(points[k], tsm1.NewValue(int64(i), 1.1)) | |
} | |
dir := MustTempDir() | |
defer os.RemoveAll(dir) | |
w := tsm1.NewWAL(dir) | |
if err := w.Open(); err != nil { | |
b.Fatalf("unexpected error opening wal: %v", err) | |
} | |
defer w.Close() | |
b.ResetTimer() | |
var wg sync.WaitGroup | |
wg.Add(concurrency) | |
for i := 0; i < concurrency; i++ { | |
go func() { | |
defer wg.Done() | |
for i := 0; i < b.N; i++ { | |
if _, err := w.WritePoints(points); err != nil { | |
b.Fatalf("unexpected error writing: %v", err) | |
} | |
} | |
}() | |
} | |
wg.Wait() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment