Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Add base benchmark for rdb parse #747

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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())
}
}
Loading