-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #77 from dolan-in/v2
Merge v2 to master
- Loading branch information
Showing
22 changed files
with
1,972 additions
and
1,356 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} |
Oops, something went wrong.