This file contains hidden or 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
func benchmarkBulkCreate(size int, b *testing.B) { | |
db, err := gorm.Open("postgres", "host=localhost port=5432 user=testuser dbname=testdb password=123456 sslmode=disable") | |
if err != nil { | |
fmt.Println(err) | |
} | |
defer db.Close() | |
users := stubUsers(b) | |
tx := db.Begin() | |
chunkList := funk.Chunk(users, size) |
This file contains hidden or 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
func benchmarkBulkCreate(size int, b *testing.B) { | |
db, err := gorm.Open("postgres", "host=localhost port=5432 user=testuser dbname=testdb password=123456 sslmode=disable") | |
if err != nil { | |
fmt.Println(err) | |
} | |
defer db.Close() | |
users := stubUsers(b) | |
tx := db.Begin() | |
chunkList := funk.Chunk(users, size) |
This file contains hidden or 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
func benchmarkBulkCreate(size int, b *testing.B) { | |
db, err := gorm.Open("postgres", "host=localhost port=5432 user=testuser dbname=testdb password=123456 sslmode=disable") | |
if err != nil { | |
fmt.Println(err) | |
} | |
defer db.Close() | |
users := stubUsers(b) | |
tx := db.Begin() | |
chunkList := funk.Chunk(users, size) |
This file contains hidden or 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
func BenchmarkBulkCreateSize1(b *testing.B) { | |
benchmarkBulkCreate(1, b) | |
} | |
func BenchmarkBulkCreateSize100(b *testing.B) { | |
benchmarkBulkCreate(100, b) | |
} | |
func BenchmarkBulkCreateSize500(b *testing.B) { | |
benchmarkBulkCreate(500, b) |
This file contains hidden or 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
func benchmarkBulkCreate(size int, b *testing.B) { | |
db, err := gorm.Open("postgres", "host=localhost port=5432 user=testuser dbname=testdb password=123456 sslmode=disable") | |
if err != nil { | |
fmt.Println(err) | |
} | |
defer db.Close() | |
users := stubUsers(b) | |
tx := db.Begin() | |
chunkList := funk.Chunk(users, size) |
This file contains hidden or 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
func BenchmarkBulkCreate(b *testing.B) { | |
db, err := gorm.Open("postgres", "host=localhost port=5432 user=testuser dbname=testdb password=123456 sslmode=disable") | |
if err != nil { | |
fmt.Println(err) | |
} | |
defer db.Close() | |
users := stubUsers(b) | |
size := 500 | |
tx := db.Begin() |
This file contains hidden or 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
func BenchmarkCreate(b *testing.B) { | |
db, err := gorm.Open("postgres", "host=localhost port=5432 user=testuser dbname=testdb password=123456 sslmode=disable") | |
if err != nil { | |
fmt.Println(err) | |
} | |
defer db.Close() | |
users := stubUsers(b) | |
tx := db.Begin() | |
valueStrings := []string{} |
This file contains hidden or 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
func BenchmarkOrmCreate(b *testing.B) { | |
db, err := gorm.Open("postgres", "host=localhost port=5432 user=testuser dbname=testdb password=123456 sslmode=disable") | |
if err != nil { | |
fmt.Println(err) | |
} | |
defer db.Close() | |
users := stubUsers(b) | |
for _, user := range users { | |
db.Create(user) |
This file contains hidden or 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
package main | |
import ( | |
"math/rand" | |
"testing" | |
) | |
const letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" | |
func genRandomString(length int) string { |
This file contains hidden or 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
package main | |
import ( | |
"fmt" | |
"github.com/jinzhu/gorm" | |
_ "github.com/jinzhu/gorm/dialects/postgres" | |
) | |
type User struct { |
NewerOlder