forked from mirrors/tar-split
tar/storage: Benchmark for bufferFileGetPutter.Put
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
This commit is contained in:
parent
505d53c95c
commit
ea73dc6f6f
1 changed files with 22 additions and 0 deletions
|
@ -2,7 +2,9 @@ package storage
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -39,6 +41,7 @@ func TestGetter(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPutter(t *testing.T) {
|
func TestPutter(t *testing.T) {
|
||||||
fp := NewDiscardFilePutter()
|
fp := NewDiscardFilePutter()
|
||||||
// map[filename]map[body]crc64sum
|
// map[filename]map[body]crc64sum
|
||||||
|
@ -60,3 +63,22 @@ func TestPutter(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func BenchmarkPutter(b *testing.B) {
|
||||||
|
files := []string{
|
||||||
|
strings.Repeat("foo", 1000),
|
||||||
|
strings.Repeat("bar", 1000),
|
||||||
|
strings.Repeat("baz", 1000),
|
||||||
|
strings.Repeat("fooz", 1000),
|
||||||
|
strings.Repeat("vbatts", 1000),
|
||||||
|
strings.Repeat("systemd", 1000),
|
||||||
|
}
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
fgp := NewBufferFileGetPutter()
|
||||||
|
for n, body := range files {
|
||||||
|
if _, _, err := fgp.Put(fmt.Sprintf("%d", n), bytes.NewBufferString(body)); err != nil {
|
||||||
|
b.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue