diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml index 01f72a5..c8e1326 100644 --- a/.idea/dataSources.xml +++ b/.idea/dataSources.xml @@ -1,13 +1,6 @@ - - postgresql - true - org.postgresql.Driver - jdbc:postgresql://localhost:5433/postgres - $ProjectFileDir$ - postgresql true @@ -43,5 +36,19 @@ jdbc:sqlserver://localhost:1433 $ProjectFileDir$ + + postgresql + true + org.postgresql.Driver + jdbc:postgresql://localhost:5433/postgres + $ProjectFileDir$ + + + postgresql + true + org.postgresql.Driver + jdbc:postgresql://localhost:5436/postgres + $ProjectFileDir$ + \ No newline at end of file diff --git a/database.go b/database.go index b1a8a67..083755a 100644 --- a/database.go +++ b/database.go @@ -122,8 +122,6 @@ func writeData(databaseType string, databases map[string]string) { } } - - type BenchmarkData struct { gorm.Model Data int @@ -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 { diff --git a/main.go b/main.go index d322cac..1d0808b 100644 --- a/main.go +++ b/main.go @@ -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()