Skip to content

Commit

Permalink
chore: Add base benchmark for rdb parse
Browse files Browse the repository at this point in the history
  • Loading branch information
Zheaoli committed Jan 1, 2024
1 parent 56abca8 commit cb9a67b
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions internal/rdb/rdb_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package rdb

import (
"context"
"testing"

"RedisShake/internal/entry"
)

// BenchmarkParseRDB is a benchmark for ParseRDB
// The baseline is "20 350030327 ns/op 213804114 B/op 1900715 allocs/op"
func BenchmarkParseRDB(b *testing.B) {
b.ReportAllocs()
b.ResetTimer()
tempChan := make(chan *entry.Entry, 1024)
updateFunc := func(offset int64) {

}
b.N = 20

for i := 0; i < b.N; i++ {
loader := NewLoader("rdb", updateFunc, "./dump.rdb", tempChan)
go func() {
for temp := range tempChan {
print(temp.CmdName)
}
}()
loader.ParseRDB(context.Background())
}
}

0 comments on commit cb9a67b

Please sign in to comment.