Skip to content

Commit

Permalink
go sqlgen: add non-ptr proto to benchmark
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
berfarah committed Oct 10, 2018
1 parent 7f449b9 commit d409814
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions sqlgen/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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 {
Expand All @@ -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 {
Expand Down

0 comments on commit d409814

Please sign in to comment.