-
Notifications
You must be signed in to change notification settings - Fork 700
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Add base benchmark for rdb parse
- Loading branch information
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) | ||
} | ||
} |