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