Skip to content

Commit

Permalink
storage: create new raftEntryCache benchmark
Browse files Browse the repository at this point in the history
```
name                 time/op
EntryCache-4         3.00ms ± 9%
EntryCacheClearTo-4   313µs ± 9%

name                 alloc/op
EntryCache-4          113kB ± 0%
EntryCacheClearTo-4  8.31kB ± 0%

name                 allocs/op
EntryCache-4          2.02k ± 0%
EntryCacheClearTo-4    14.0 ± 0%
```

Release note: None
  • Loading branch information
nvanbenschoten committed Sep 13, 2018
1 parent 0386163 commit 5a13ea2
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions pkg/storage/entry_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,29 @@ func TestEntryCacheEviction(t *testing.T) {
}
}

func BenchmarkEntryCache(b *testing.B) {
rangeID := roachpb.RangeID(1)
ents := make([]raftpb.Entry, 1000)
for i := range ents {
ents[i] = newEntry(uint64(i+1), 8)
}

b.ResetTimer()
for i := 0; i < b.N; i++ {
b.StopTimer()
rec := newRaftEntryCache(8 * uint64(len(ents)*len(ents[0].Data)))
for i := roachpb.RangeID(0); i < 10; i++ {
if i != rangeID {
rec.addEntries(i, ents)
}
}
b.StartTimer()
rec.addEntries(rangeID, ents)
_, _, _, _ = rec.getEntries(nil, rangeID, 0, uint64(len(ents)-10), noLimit)
rec.clearTo(rangeID, uint64(len(ents)-10))
}
}

func BenchmarkEntryCacheClearTo(b *testing.B) {
rangeID := roachpb.RangeID(1)
ents := make([]raftpb.Entry, 1000)
Expand Down

0 comments on commit 5a13ea2

Please sign in to comment.