nostrdb

an unfairly fast embedded nostr database backed by lmdb
git clone git://jb55.com/nostrdb
Log | Files | Refs | Submodules | README | LICENSE

commit 4435501754dca260c04f392e87356b6caf212c67
parent 750346cce36d7e533ec6e88fbd3011d9a753b91d
Author: William Casarin <jb55@jb55.com>
Date:   Fri, 11 Aug 2023 21:08:27 -0700

bench: switch to monotonic clock for benchmarking

Diffstat:
Mbench-ingest.c | 4++--
Mbench.c | 4++--
2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/bench-ingest.c b/bench-ingest.c @@ -21,7 +21,7 @@ static int bench_parser(int times) assert(ndb_init(&ndb, mapsize, ingester_threads)); read_file("testdata/contacts-event.json", (unsigned char*)json, alloc_size, &written); - clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &t1); + clock_gettime(CLOCK_MONOTONIC, &t1); for (i = 0; i < times; i++) { ndb_process_event(ndb, json, written); @@ -30,7 +30,7 @@ static int bench_parser(int times) free(json); ndb_destroy(ndb); - clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &t2); + clock_gettime(CLOCK_MONOTONIC, &t2); nanos = (t2.tv_sec - t1.tv_sec) * (long)1e9 + (t2.tv_nsec - t1.tv_nsec); ms = nanos / 1e6; diff --git a/bench.c b/bench.c @@ -14,13 +14,13 @@ static int bench_parser(int times, const char *json, int len) long nanos, ms; struct ndb_note *note; - clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &t1); + clock_gettime(CLOCK_MONOTONIC, &t1); for (i = 0; i < times; i++) { if (!ndb_note_from_json(json, len, &note, buf, sizeof(buf))) { return 0; } } - clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &t2); + clock_gettime(CLOCK_MONOTONIC, &t2); nanos = (t2.tv_sec - t1.tv_sec) * (long)1e9 + (t2.tv_nsec - t1.tv_nsec); ms = nanos / 1e6;