-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
44 lines (32 loc) · 1020 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package main
import (
"fmt"
"time"
_ "github.com/lib/pq"
"github.com/tprovoost/pg-vs-sqlboiler/modules"
"github.com/tprovoost/pg-vs-sqlboiler/modules/shared"
"github.com/volatiletech/sqlboiler/v4/boil"
)
func main() {
boil.DebugMode = false
// First clean up the database.
bench := modules.BoilerRunBenchmark(modules.BoilerCleanUp, 1)
fmt.Printf("Clean up lasted: %d ms\n", bench.GetDuration().Milliseconds())
var suite shared.BenchmarkSuite
suite.ReadOne = []shared.Benchmark{
modules.BoilerRunBenchmark(modules.BoilerReadOne, 4000),
modules.PGRunBenchmark(modules.PGReadOne, 4000),
}
suite.Insert = []shared.Benchmark{
modules.BoilerRunBenchmark(modules.BoilerInsert, 1000),
modules.PGRunBenchmark(modules.PGInsert, 1000),
}
suite.FetchIn = []shared.Benchmark{
modules.BoilerRunBenchmark(modules.BoilerFetchIn, 1000),
modules.PGRunBenchmark(modules.PGFetchIn, 1000),
}
suite.Print()
}
func averageDuration(d time.Duration, N int) int64 {
return d.Microseconds() / int64(N)
}