mirror of
https://github.com/pgvector/pgvector.git
synced 2026-07-02 02:31:16 +08:00
Added support for benchmarking
This commit is contained in:
@@ -10,6 +10,10 @@
|
||||
#include "utils/tuplesort.h"
|
||||
#include "vector.h"
|
||||
|
||||
#ifdef IVFFLAT_BENCH
|
||||
#include "portability/instr_time.h"
|
||||
#endif
|
||||
|
||||
#if PG_VERSION_NUM < 90600
|
||||
#error "Requires PostgreSQL 9.6+"
|
||||
#endif
|
||||
@@ -43,6 +47,21 @@
|
||||
#define IvfflatPageGetOpaque(page) ((IvfflatPageOpaque) PageGetSpecialPointer(page))
|
||||
#define IvfflatPageGetMeta(page) ((IvfflatMetaPageData *) PageGetContents(page))
|
||||
|
||||
#ifdef IVFFLAT_BENCH
|
||||
#define Bench(name, code) \
|
||||
do { \
|
||||
instr_time start; \
|
||||
instr_time duration; \
|
||||
INSTR_TIME_SET_CURRENT(start); \
|
||||
(code); \
|
||||
INSTR_TIME_SET_CURRENT(duration); \
|
||||
INSTR_TIME_SUBTRACT(duration, start); \
|
||||
elog(INFO, "%s: %f ms", name, INSTR_TIME_GET_MILLISEC(duration)); \
|
||||
} while (0)
|
||||
#else
|
||||
#define Bench(name, code) (code)
|
||||
#endif
|
||||
|
||||
#if PG_VERSION_NUM < 100000
|
||||
#define ItemPointerGetBlockNumberNoCheck ItemPointerGetBlockNumber
|
||||
#define ItemPointerGetOffsetNumberNoCheck ItemPointerGetOffsetNumber
|
||||
|
||||
@@ -154,6 +154,8 @@ GetScanItems(IndexScanDesc scan, Datum value)
|
||||
UnlockReleaseBuffer(buf);
|
||||
}
|
||||
}
|
||||
|
||||
tuplesort_performsort(so->sortstate);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -269,9 +271,8 @@ ivfflatgettuple(IndexScanDesc scan, ScanDirection dir)
|
||||
return false;
|
||||
}
|
||||
|
||||
GetScanLists(scan, value);
|
||||
GetScanItems(scan, value);
|
||||
tuplesort_performsort(so->sortstate);
|
||||
Bench("GetScanLists", GetScanLists(scan, value));
|
||||
Bench("GetScanItems", GetScanItems(scan, value));
|
||||
so->first = false;
|
||||
|
||||
/* Clean up if we allocated a new value */
|
||||
|
||||
Reference in New Issue
Block a user