Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
Took 1 hour 15 minutes
  • Loading branch information
petrjahoda committed Jan 8, 2021
1 parent cd36aaa commit f228a17
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 23 deletions.
21 changes: 14 additions & 7 deletions .idea/dataSources.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions database.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,6 @@ func writeData(databaseType string, databases map[string]string) {
}
}



type BenchmarkData struct {
gorm.Model
Data int
Expand Down Expand Up @@ -162,17 +160,18 @@ func createDatabaseAndTable(databaseType string, databases map[string]string) {
sqlDB, _ := database.DB()
defer sqlDB.Close()
if err != nil {
fmt.Println("Problem opening database: "+err.Error())
fmt.Println("Problem opening database: " + err.Error())
return
}
fmt.Println(databaseType + " connected")

if !database.Migrator().HasTable(&BenchmarkData{}) {
err := database.Migrator().CreateTable(&BenchmarkData{})
if err != nil {
fmt.Println("Cannot create table: " + err.Error())
return
}
database.Raw("SELECT create_hypertable('benchmark_data', 'created_at');")
} else {
err := database.Migrator().AutoMigrate(&BenchmarkData{})
if err != nil {
Expand Down
30 changes: 18 additions & 12 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,24 @@ func (p program) run() {
writingSync.Lock()
programIsRunning = true
writingSync.Unlock()
writeBenchmark("postgres")
writeBenchmark("timescale")
writeBenchmark("mysql")
writeBenchmark("mariadb")
writeBenchmark("percona")
writeBenchmark("sqlserver")
readBenchmark("postgres")
readBenchmark("timescale")
readBenchmark("mysql")
readBenchmark("mariadb")
readBenchmark("percona")
readBenchmark("sqlserver")
for i := 0; i < 5; i++ {
writeBenchmark("postgres")
//writeBenchmark("timescale")
//writeBenchmark("mysql")
//writeBenchmark("mariadb")
//writeBenchmark("percona")
//writeBenchmark("sqlserver")
time.Sleep(1 * time.Second)
}
for i := 0; i < 5; i++ {
readBenchmark("postgres")
//readBenchmark("timescale")
//readBenchmark("mysql")
//readBenchmark("mariadb")
//readBenchmark("percona")
//readBenchmark("sqlserver")
time.Sleep(1 * time.Second)
}
writingSync.Lock()
programIsRunning = false
writingSync.Unlock()
Expand Down

0 comments on commit f228a17

Please sign in to comment.