diff --git a/README.org b/README.org index 589826bed857436a7b586bb7de20de571c438a67..733bd77a2b8e928f07831c0326bfaf98cff803e7 100644 --- a/README.org +++ b/README.org @@ -189,3 +189,27 @@ update time cost: 2.72s select time cost: 0.33s update time cost: 2.75s -- + +** 2019-02-23 pg 9.6, ghc 8.2.2, lts 11.7 +seconds: 0.249821547 +seconds: 2.703614265 +-- +seconds: 0.252873544 +seconds: 2.662445433 +-- +seconds: 0.244120763 +seconds: 2.655961013 +-- + +** 2019-02-23 pg 9.6, gcc 6.3.0, libpq-dev 10.3-1 +0.170 +2.598 +-- +0.172 +2.551 +-- +0.178 +2.562 +-- +0.172 +2.589 diff --git a/c-libpq5/Makefile b/c-libpq5/Makefile index 72b174d7a4d307d74408f2b4ef8848e2021ddc2c..a6eabcda11009a70d8bf6a133ce9abb66e278721 100644 --- a/c-libpq5/Makefile +++ b/c-libpq5/Makefile @@ -1,3 +1,5 @@ -CFLAGS = -std=c99 -O2 -fPIC -pedantic -Wall -Wextra -I/usr/include/postgresql +CFLAGS = -std=c99 -O2 -fPIC -pedantic -Wall -Wextra -Werror -I/usr/include/postgresql LDFLAGS = -lpq +run: bench + ./bench bench: bench.c diff --git a/c-libpq5/bench b/c-libpq5/bench index 2f019ab6a9ab8c3732ed5b791bb2848ed2901af0..72b059e29322aaa1d514c48b3ece902a6523076f 100755 Binary files a/c-libpq5/bench and b/c-libpq5/bench differ diff --git a/c-libpq5/bench.c b/c-libpq5/bench.c index 59283929eb581650ba7cde1796005d28faacea04..16a9552de0aa558cb7f5199ef6297e3eecdbc1ce 100644 --- a/c-libpq5/bench.c +++ b/c-libpq5/bench.c @@ -3,6 +3,7 @@ */ #include <stdio.h> #include <stdlib.h> +#include <string.h> #include <sys/time.h> #include <libpq-fe.h> @@ -23,7 +24,7 @@ select_test(PGconn *conn) res = PQexec(conn, "SELECT id, bar FROM foo"); if (PQresultStatus(res) != PGRES_TUPLES_OK) { - fprintf(stderr, "SELECT command failed: %s", + fprintf(stderr, "SELECT command failed: %s\n", PQerrorMessage(conn)); PQclear(res); exit_nicely(conn); @@ -40,7 +41,7 @@ update_test(PGconn *conn) res = PQexec(conn, "UPDATE foo SET bar=bar+1 WHERE id=1"); if (PQresultStatus(res) != PGRES_COMMAND_OK) { - fprintf(stderr, "UPDATE command failed: %s", + fprintf(stderr, "UPDATE command failed: %s\n", PQerrorMessage(conn)); PQclear(res); exit_nicely(conn); @@ -59,13 +60,24 @@ int main() { struct timeval start, end; - const char *conninfo = "host=localhost dbname=t1 user=t1 password=fNfwREMqO69TB9YqE+/OzF5/k+s="; + const char *password; + const char *conninfo_part = "host=localhost dbname=t1 user=t1 password="; + char *conninfo; PGconn *conn; + password = getenv("PG_T1_PASSWORD"); + if (password == NULL) { + fprintf(stderr, "Please define PG_T1_PASSWORD environment variable\n"); + exit(1); + } + + conninfo = (char*) malloc(1 + strlen(conninfo_part) + strlen(password)); + strcat(conninfo, conninfo_part); + strcat(conninfo, password); conn = PQconnectdb(conninfo); if (PQstatus(conn) != CONNECTION_OK) { - fprintf(stderr, "Connection to database failed: %s", + fprintf(stderr, "Connection to database failed: %s\n", PQerrorMessage(conn)); exit_nicely(conn); } diff --git a/haskell-postgres-simple/Bench.hs b/haskell-postgres-simple/Bench.hs index bfdb7f9eaf699e987caaeb7c80db8049aa1c48e2..d71f03c4882a5f2b3b544af9b7ea3284086d7b23 100644 --- a/haskell-postgres-simple/Bench.hs +++ b/haskell-postgres-simple/Bench.hs @@ -1,5 +1,6 @@ module Main where +import System.Environment (lookupEnv) import Control.Monad import Text.Printf import Data.Time.Clock @@ -26,7 +27,11 @@ timeit action = do main :: IO () main = do - conn <- connectPostgreSQL "host=localhost dbname=t1 user=t1 password=fNfwREMqO69TB9YqE+/OzF5/k+s=" - timeit $ selectTest conn - timeit $ updateTest conn - close conn + passwordMaybe <- lookupEnv "PG_T1_PASSWORD" + case passwordMaybe of + Nothing -> printf "Error: Please define PG_T1_PASSWORD environment variable" + Just password -> do + conn <- connectPostgreSQL "host=localhost dbname=t1 user=t1 password=62IWgtWiPCZdt8qu" + timeit $ selectTest conn + timeit $ updateTest conn + close conn diff --git a/haskell-postgres-simple/Makefile b/haskell-postgres-simple/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..b3466ffc3b24cc94ac685d8f8ef5818d13ba8368 --- /dev/null +++ b/haskell-postgres-simple/Makefile @@ -0,0 +1,4 @@ +run: + stack build + stack exec bench +.PHONY: run diff --git a/haskell-postgres-simple/stack.yaml b/haskell-postgres-simple/stack.yaml index ecf897a29ae14f0a135b4cc21bcf8eb627958fc9..27ebe432219494f212371fe073d3f8e46a48877b 100644 --- a/haskell-postgres-simple/stack.yaml +++ b/haskell-postgres-simple/stack.yaml @@ -15,7 +15,7 @@ # resolver: # name: custom-snapshot # location: "./custom-snapshot.yaml" -resolver: lts-5.18 +resolver: lts-11.7 # User packages to be built. # Various formats can be used as shown in the example below. diff --git a/java-jdbc/Makefile b/java-jdbc/Makefile index f65418146d06d9018867f8ce145f62997822de88..48633250fcf5ec3d10a24e6a08dd51770f2aaf1f 100644 --- a/java-jdbc/Makefile +++ b/java-jdbc/Makefile @@ -1,3 +1,3 @@ run: - PG_T1_PASSWORD="62IWgtWiPCZdt8qu" ./gradlew build run + ./gradlew build run .PHONY: run diff --git a/python-psycopg2/Makefile b/python-psycopg2/Makefile index b587afe97ccb7081d96bb4b3660acd39cde148e3..f7bc82fb4c68c63cca0eaab9e09edf62571f9226 100644 --- a/python-psycopg2/Makefile +++ b/python-psycopg2/Makefile @@ -1,3 +1,3 @@ run: - PG_T1_PASSWORD="62IWgtWiPCZdt8qu" python bench.py + python bench.py .PHONY: run