From: Robert Haas Date: Wed, 25 Jul 2012 16:24:24 +0000 (-0400) Subject: Time inserts, searches. X-Git-Url: http://git.postgresql.org/gitweb/static/maillist.html?a=commitdiff_plain;h=f310b48e12c10922af6e1ee124e4918129785679;p=users%2Frhaas%2Fpostgres.git Time inserts, searches. --- diff --git a/contrib/hashtest/hashtest.c b/contrib/hashtest/hashtest.c index 94120216a7..90cc2f1681 100644 --- a/contrib/hashtest/hashtest.c +++ b/contrib/hashtest/hashtest.c @@ -7,6 +7,7 @@ #include "funcapi.h" #include "miscadmin.h" +#include "portability/instr_time.h" #include "storage/ipc.h" #include "utils/chash.h" @@ -96,6 +97,11 @@ test_chash(PG_FUNCTION_ARGS) { uint32 i; hentry e; + instr_time t0, + t1, + t2; + + INSTR_TIME_SET_CURRENT(t0); for (i = 0; i < 1000000; ++i) { @@ -111,6 +117,8 @@ test_chash(PG_FUNCTION_ARGS) elog(LOG, "insert %u: worked twice", i); } + INSTR_TIME_SET_CURRENT(t1); + for (i = 0; i < 1000000; ++i) { bool ok; @@ -123,6 +131,14 @@ test_chash(PG_FUNCTION_ARGS) elog(LOG, "search %u: found %u", i, e.val); } + INSTR_TIME_SET_CURRENT(t2); + INSTR_TIME_SUBTRACT(t2, t1); + INSTR_TIME_SUBTRACT(t1, t0); + + elog(LOG, "inserts: %lu us; searches: %lu us", + (unsigned long) INSTR_TIME_GET_MICROSEC(t2), + (unsigned long) INSTR_TIME_GET_MICROSEC(t1)); + PG_RETURN_VOID(); } @@ -169,6 +185,11 @@ Datum test_dynahash(PG_FUNCTION_ARGS) { uint32 i; + instr_time t0, + t1, + t2; + + INSTR_TIME_SET_CURRENT(t0); for (i = 0; i < 1000000; ++i) { @@ -182,6 +203,8 @@ test_dynahash(PG_FUNCTION_ARGS) elog(LOG, "insert %u: worked twice", i); } + INSTR_TIME_SET_CURRENT(t1); + for (i = 0; i < 1000000; ++i) { bool ok; @@ -194,5 +217,13 @@ test_dynahash(PG_FUNCTION_ARGS) elog(LOG, "search %u: found %u", i, val); } + INSTR_TIME_SET_CURRENT(t2); + INSTR_TIME_SUBTRACT(t2, t1); + INSTR_TIME_SUBTRACT(t1, t0); + + elog(LOG, "inserts: %lu us; searches: %lu us", + (unsigned long) INSTR_TIME_GET_MICROSEC(t2), + (unsigned long) INSTR_TIME_GET_MICROSEC(t1)); + PG_RETURN_VOID(); }