Created
June 25, 2020 02:23
-
-
Save pjebs/5c3f81f6001aff1b4dd3d7b5e451839a to your computer and use it in GitHub Desktop.
go benchmark structure
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
func Benchmark(b *testing.B) { | |
setup() | |
defer cleanup() | |
limits := []int{ | |
5, | |
50, | |
500, | |
10000, | |
} | |
for _, lim := range limits { // Fetch varying number of rows | |
lim := lim | |
// Benchmark dbq | |
b.Run(fmt.Sprintf("dbq limit:%d", lim), func(b *testing.B) { | |
for i := 0; i < b.N; i++ { | |
} | |
}) | |
// Benchmark sqlx | |
b.Run(fmt.Sprintf("sqlx limit:%d", lim), func(b *testing.B) { | |
for i := 0; i < b.N; i++ { | |
} | |
}) | |
// Benchmark gorm | |
b.Run(fmt.Sprintf("gorm limit:%d", lim), func(b *testing.B) { | |
for i := 0; i < b.N; i++ { | |
} | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment