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

Add benchmark test suite for gocql.Marshal/Unmarshal #302

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sylwiaszunejko
Copy link
Collaborator

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<...>>>.

Fixes: #295

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<...>>>.
Copy link
Collaborator

@dkropachev dkropachev left a 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
Copy link
Collaborator

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

Comment on lines +17 to +28
// 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)
}
Copy link
Collaborator

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`

Copy link
Collaborator Author

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?

Copy link
Collaborator

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")
Copy link
Collaborator

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:

  1. Small: +-100b
  2. Medium: 1kb
  3. Big: 1M
  4. Huge: 10M

for text let's make it a json.
for blob a binary data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Benchmark test suite for gocql.Marshal
2 participants