From d4098145136dd0aaf204a3ca57c82042cdfb98b3 Mon Sep 17 00:00:00 2001 From: Bernardo Farah Date: Wed, 10 Oct 2018 10:56:30 -0700 Subject: [PATCH] go sqlgen: add non-ptr proto to benchmark What we see here is an additional allocation for the non-ptr proto to the heap. We expect this, since we have to create a new pointer in order to satisfy the marshaler interface. We deem this cost worth the additional safety of not having to deal with pointers. Since people have to opt-in to use this feature there isn't a noticeable difference to existing code-paths. --- sqlgen/integration_test.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/sqlgen/integration_test.go b/sqlgen/integration_test.go index 9c1629d7b..775aaa0e2 100644 --- a/sqlgen/integration_test.go +++ b/sqlgen/integration_test.go @@ -8,6 +8,7 @@ import ( _ "github.com/go-sql-driver/mysql" "github.com/samsarahq/thunder/batch" + "github.com/samsarahq/thunder/internal/proto" "github.com/samsarahq/thunder/internal/testfixtures" "github.com/stretchr/testify/assert" ) @@ -20,10 +21,11 @@ func setup() (*testfixtures.TestDatabase, *DB, error) { if _, err = testDb.Exec(` CREATE TABLE users ( - id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY, - name VARCHAR(255), - uuid VARCHAR(255), - mood VARCHAR(255), + id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY, + name VARCHAR(255), + uuid VARCHAR(255), + mood VARCHAR(255), + proto BLOB, implicit_null VARCHAR(255) ) `); err != nil { @@ -40,7 +42,8 @@ type User struct { Name string Uuid testfixtures.CustomType Mood *testfixtures.CustomType - ImplicitNull string `sql:",implicitnull"` + Proto proto.ExampleEvent `sql:",binary"` + ImplicitNull string `sql:",implicitnull"` } type Complex struct {