mirror of
https://github.com/facebookresearch/faiss.git
synced 2025-06-03 21:54:02 +08:00
Enable servicelab regression testing.
Summary: Start migration of existing benchmarks to Google's Benchmark library + register benchmark to servicelab. The benchmark should be automatically registered to servicelab once this diff lands according to https://www.internalfb.com/intern/wiki/ServiceLab/Use_Cases/Benchmarks_(C++)/#servicelab-job. Reviewed By: mdouze Differential Revision: D35397782 fbshipit-source-id: 317db2527f12ddde0631cacc3085c634afdd0e37
This commit is contained in:
parent
bb4c987b5c
commit
7c9d979d66
@ -8,6 +8,7 @@
|
||||
#include <omp.h>
|
||||
#include <cstdio>
|
||||
|
||||
#include <benchmark/benchmark.h>
|
||||
#include <faiss/impl/ScalarQuantizer.h>
|
||||
#include <faiss/utils/distances.h>
|
||||
#include <faiss/utils/random.h>
|
||||
@ -15,7 +16,7 @@
|
||||
|
||||
using namespace faiss;
|
||||
|
||||
int main() {
|
||||
static void bench(benchmark::State& state) {
|
||||
int d = 128;
|
||||
int n = 2000;
|
||||
|
||||
@ -62,17 +63,16 @@ int main() {
|
||||
dc->code_size = sq.code_size;
|
||||
printf("code size: %ld\n", dc->code_size);
|
||||
|
||||
double sum_dis = 0;
|
||||
double t0 = getmillisecs();
|
||||
for (int i = 0; i < n; i++) {
|
||||
dc->set_query(&x[i * d]);
|
||||
for (int j = 0; j < n; j++) {
|
||||
sum_dis += (*dc)(j);
|
||||
for (auto _ : state) {
|
||||
float sum_dis = 0;
|
||||
for (int i = 0; i < n; i++) {
|
||||
dc->set_query(&x[i * d]);
|
||||
for (int j = 0; j < n; j++) {
|
||||
benchmark::DoNotOptimize(sum_dis += (*dc)(j));
|
||||
}
|
||||
}
|
||||
}
|
||||
printf("distances computed in %.3f ms, checksum=%g\n",
|
||||
getmillisecs() - t0,
|
||||
sum_dis);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
BENCHMARK(bench);
|
||||
BENCHMARK_MAIN();
|
||||
|
Loading…
x
Reference in New Issue
Block a user