-
Notifications
You must be signed in to change notification settings - Fork 57
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
Add benchmark test suite for gocql.Marshal/Unmarshal #302
base: master
Are you sure you want to change the base?
Add benchmark test suite for gocql.Marshal/Unmarshal #302
Conversation
Test added for: * Simple data types: int, blob, text, uuid, duration, timestamp * Complex data types: list, map, set udt,tuple. * 3 level complex data type: list<map<udt<...>>>.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please make tests looks like this:
func BenchmarkSerialization(b *testing.B) {
b.Run("SimpleTypes", func(b *testing.B) {
b.Run("Int", func(b *testing.B) {
b.Run("Marshal", func(b *testing.B) {
}
b.Run("Unmarshal", func(b *testing.B) {
}
}
}
}
@@ -0,0 +1,331 @@ | |||
package gocql_bench |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's move it to tests/bench/bench_marshal_test.go
// Marshal | ||
marshaled, err := gocql.Marshal(tType, val) | ||
if err != nil { | ||
b.Fatal(err) | ||
} | ||
|
||
// Unmarshal | ||
var unmarshaled int | ||
err = gocql.Unmarshal(tType, marshaled, &unmarshaled) | ||
if err != nil { | ||
b.Fatal(err) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for being confusing, but it is better to test Marshal and Unmarshal separately`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but to test Unmarshal I need some marshled data, so in the test for unmarshaling I need to run both Marshal()
and Unmarshal()
? Or should we for now just test Marshal
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
call marshal once outside of the test just before t.run
b.Run("Blob", func(b *testing.B) { | ||
tType := gocql.NewNativeType(4, gocql.TypeBlob, "") | ||
|
||
var val = []byte("test blob data") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for blob and text we would want to test following cases:
- Small: +-100b
- Medium: 1kb
- Big: 1M
- Huge: 10M
for text let's make it a json.
for blob a binary data.
Test added for:
Fixes: #295