mirror of https://github.com/restic/restic.git
Make backend benchmarks fairer by removing checks
Checking whether the right data is returned takes up half the time in some benchmarks. Results for local backend benchmarks on linux/amd64: name old time/op new time/op delta Backend/BenchmarkLoadFile-8 4.89ms ± 0% 2.72ms ± 1% -44.26% (p=0.008 n=5+5) Backend/BenchmarkLoadPartialFile-8 936µs ± 6% 439µs ±15% -53.07% (p=0.008 n=5+5) Backend/BenchmarkLoadPartialFileOffset-8 940µs ± 1% 456µs ±10% -51.50% (p=0.008 n=5+5) Backend/BenchmarkSave-8 23.9ms ±14% 24.8ms ±41% ~ (p=0.690 n=5+5) name old speed new speed delta Backend/BenchmarkLoadFile-8 3.43GB/s ± 0% 6.16GB/s ± 1% +79.40% (p=0.008 n=5+5) Backend/BenchmarkLoadPartialFile-8 4.48GB/s ± 6% 9.63GB/s ±14% +114.78% (p=0.008 n=5+5) Backend/BenchmarkLoadPartialFileOffset-8 4.46GB/s ± 1% 9.22GB/s ±10% +106.74% (p=0.008 n=5+5) Backend/BenchmarkSave-8 706MB/s ±13% 698MB/s ±31% ~ (p=0.690 n=5+5)
This commit is contained in:
parent
84475aa3a8
commit
f4cd2a7120
|
@ -48,17 +48,17 @@ func (s *Suite) BenchmarkLoadFile(t *testing.B) {
|
|||
n, ierr = io.ReadFull(rd, buf)
|
||||
return ierr
|
||||
})
|
||||
if err != nil {
|
||||
|
||||
t.StopTimer()
|
||||
switch {
|
||||
case err != nil:
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if n != length {
|
||||
case n != length:
|
||||
t.Fatalf("wrong number of bytes read: want %v, got %v", length, n)
|
||||
}
|
||||
|
||||
if !bytes.Equal(data, buf) {
|
||||
case !bytes.Equal(data, buf):
|
||||
t.Fatalf("wrong bytes returned")
|
||||
}
|
||||
t.StartTimer()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -85,18 +85,17 @@ func (s *Suite) BenchmarkLoadPartialFile(t *testing.B) {
|
|||
n, ierr = io.ReadFull(rd, buf)
|
||||
return ierr
|
||||
})
|
||||
if err != nil {
|
||||
|
||||
t.StopTimer()
|
||||
switch {
|
||||
case err != nil:
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if n != testLength {
|
||||
case n != testLength:
|
||||
t.Fatalf("wrong number of bytes read: want %v, got %v", testLength, n)
|
||||
}
|
||||
|
||||
if !bytes.Equal(data[:testLength], buf) {
|
||||
case !bytes.Equal(data[:testLength], buf):
|
||||
t.Fatalf("wrong bytes returned")
|
||||
}
|
||||
|
||||
t.StartTimer()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -124,17 +123,17 @@ func (s *Suite) BenchmarkLoadPartialFileOffset(t *testing.B) {
|
|||
n, ierr = io.ReadFull(rd, buf)
|
||||
return ierr
|
||||
})
|
||||
if err != nil {
|
||||
|
||||
t.StopTimer()
|
||||
switch {
|
||||
case err != nil:
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if n != testLength {
|
||||
case n != testLength:
|
||||
t.Fatalf("wrong number of bytes read: want %v, got %v", testLength, n)
|
||||
}
|
||||
|
||||
if !bytes.Equal(data[testOffset:testOffset+testLength], buf) {
|
||||
case !bytes.Equal(data[testOffset:testOffset+testLength], buf):
|
||||
t.Fatalf("wrong bytes returned")
|
||||
}
|
||||
t.StartTimer()
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue