Add Go/PostgreSQL version
This commit is contained in:
parent
5b5d00e205
commit
8fd1912537
6
Results
6
Results
|
@ -33,3 +33,9 @@ rorschach:~database_connect_bench 0:14 :-) 1099% time ./dcb_perl_psql
|
|||
0.00254458002746105 session 2
|
||||
./dcb_perl_psql 0.05s user 0.01s system 93% cpu 0.068 total
|
||||
|
||||
trintignant:~/wrk/database_connect_bench 19:29 :-) 1077% time ./dcb_go_psql
|
||||
2021-05-07 19:32:40.307679 +0200 CEST
|
||||
0.017314667 connect
|
||||
0.0178164 session
|
||||
./dcb_go_psql 0.01s user 0.01s system 52% cpu 0.044 total
|
||||
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"time"
|
||||
"fmt"
|
||||
"log"
|
||||
"database/sql"
|
||||
|
||||
_ "github.com/lib/pq"
|
||||
)
|
||||
|
||||
func main() {
|
||||
t0 := time.Now()
|
||||
db, err := sql.Open("postgres", "host=/run/postgresql")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
tx, _ := db.Begin()
|
||||
d1 := time.Since(t0)
|
||||
row := tx.QueryRow("select current_timestamp")
|
||||
var db_ts time.Time
|
||||
row.Scan(&db_ts)
|
||||
fmt.Println(db_ts)
|
||||
db.Close()
|
||||
d2 := time.Since(t0)
|
||||
fmt.Println(d1.Seconds(), "connect")
|
||||
fmt.Println(d2.Seconds(), "session")
|
||||
}
|
Loading…
Reference in New Issue