#include "funcapi.h"
#include "miscadmin.h"
+#include "portability/instr_time.h"
#include "storage/ipc.h"
#include "utils/chash.h"
{
uint32 i;
hentry e;
+ instr_time t0,
+ t1,
+ t2;
+
+ INSTR_TIME_SET_CURRENT(t0);
for (i = 0; i < 1000000; ++i)
{
elog(LOG, "insert %u: worked twice", i);
}
+ INSTR_TIME_SET_CURRENT(t1);
+
for (i = 0; i < 1000000; ++i)
{
bool ok;
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();
}
test_dynahash(PG_FUNCTION_ARGS)
{
uint32 i;
+ instr_time t0,
+ t1,
+ t2;
+
+ INSTR_TIME_SET_CURRENT(t0);
for (i = 0; i < 1000000; ++i)
{
elog(LOG, "insert %u: worked twice", i);
}
+ INSTR_TIME_SET_CURRENT(t1);
+
for (i = 0; i < 1000000; ++i)
{
bool ok;
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();
}