Skip to content

Commit

Permalink
Merge pull request #77 from dolan-in/v2
Browse files Browse the repository at this point in the history
Merge v2 to master
  • Loading branch information
wildan2711 committed Jan 2, 2021
2 parents 30c32f8 + 34e6e5f commit 9cd4dfd
Show file tree
Hide file tree
Showing 22 changed files with 1,972 additions and 1,356 deletions.
342 changes: 229 additions & 113 deletions README.md

Large diffs are not rendered by default.

75 changes: 75 additions & 0 deletions bench_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package dgman

import "testing"

type FlatStruct struct {
UID string `json:"uid,omitempty"`
Field1 string `json:"field1,omitempty"`
Field2 int `json:"field2,omitempty"`
Field3 bool `json:"field3,omitempty"`
Field4 []int `json:"field4,omitempty"`
Field5 []string `json:"field5,omitempty"`
DType []string `json:"dgraph.type"`
}

func createFlatStruct() FlatStruct {
return FlatStruct{
Field1: "field 1",
Field2: 2,
Field3: true,
Field4: []int{1, 2, 3, 4},
Field5: []string{"test data 1", "test data 2", "test data 3", "test data 4"},
}
}

func BenchmarkMutateBasic(b *testing.B) {
c := newDgraphClient()
CreateSchema(c, FlatStruct{})
defer dropAll(c)

for n := 0; n < b.N; n++ {
data := createFlatStruct()

tx := NewTxn(c).SetCommitNow()
tx.MutateBasic(&data)
}
}

func BenchmarkMutate(b *testing.B) {
c := newDgraphClient()
CreateSchema(c, FlatStruct{})
defer dropAll(c)

for n := 0; n < b.N; n++ {
data := createTestUser()

tx := NewTxn(c).SetCommitNow()
tx.Mutate(&data)
}
}

func BenchmarkMutateBasicNested(b *testing.B) {
c := newDgraphClient()
CreateSchema(c, TestUser{})
defer dropAll(c)

for n := 0; n < b.N; n++ {
data := createTestUser()

tx := NewTxn(c).SetCommitNow()
tx.MutateBasic(&data)
}
}

func BenchmarkMutateNested(b *testing.B) {
c := newDgraphClient()
CreateSchema(c, TestUser{})
defer dropAll(c)

for n := 0; n < b.N; n++ {
data := createTestUser()

tx := NewTxn(c).SetCommitNow()
tx.Mutate(&data)
}
}

0 comments on commit 9cd4dfd

Please sign in to comment.