diff options
author | Andrew Tridgell <tridge@samba.org> | 2009-05-26 09:24:37 +1000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2009-05-26 09:24:37 +1000 |
commit | e15027155d3d880abde83124e252b3dd10a9aae4 (patch) | |
tree | 9eaf2c03e27f588a0d0fccadd9819b3b5e87ce65 /lib | |
parent | b335618d1743599588902cfd2be4ae37150b239d (diff) | |
download | samba-e15027155d3d880abde83124e252b3dd10a9aae4.tar.gz samba-e15027155d3d880abde83124e252b3dd10a9aae4.tar.xz samba-e15027155d3d880abde83124e252b3dd10a9aae4.zip |
added some more speed tests to tdbtool
This adds 3 simple speed tests to tdbtool, for transaction store,
store and fetch.
On my laptop this shows transactions costing about 10ms
Diffstat (limited to 'lib')
-rw-r--r-- | lib/tdb/tools/tdbtool.c | 65 |
1 files changed, 59 insertions, 6 deletions
diff --git a/lib/tdb/tools/tdbtool.c b/lib/tdb/tools/tdbtool.c index b4ec095a394..3220e47b138 100644 --- a/lib/tdb/tools/tdbtool.c +++ b/lib/tdb/tools/tdbtool.c @@ -392,15 +392,68 @@ static void speed_tdb(const char *tlimit) { unsigned timelimit = tlimit?atoi(tlimit):0; double t; - int ops=0; - if (timelimit == 0) timelimit = 10; + int ops; + if (timelimit == 0) timelimit = 5; + + ops = 0; + printf("Testing store speed for %u seconds\n", timelimit); + _start_timer(); + do { + long int r = random(); + TDB_DATA key, dbuf; + key.dptr = "store test"; + key.dsize = strlen(key.dptr); + dbuf.dptr = (unsigned char *)&r; + dbuf.dsize = sizeof(r); + tdb_store(tdb, key, dbuf, TDB_REPLACE); + t = _end_timer(); + ops++; + } while (t < timelimit); + printf("%10.3f ops/sec\n", ops/t); + + ops = 0; + printf("Testing fetch speed for %u seconds\n", timelimit); + _start_timer(); + do { + long int r = random(); + TDB_DATA key, dbuf; + key.dptr = "store test"; + key.dsize = strlen(key.dptr); + dbuf.dptr = (unsigned char *)&r; + dbuf.dsize = sizeof(r); + tdb_fetch(tdb, key); + t = _end_timer(); + ops++; + } while (t < timelimit); + printf("%10.3f ops/sec\n", ops/t); + + ops = 0; + printf("Testing transaction speed for %u seconds\n", timelimit); + _start_timer(); + do { + long int r = random(); + TDB_DATA key, dbuf; + key.dptr = "transaction test"; + key.dsize = strlen(key.dptr); + dbuf.dptr = (unsigned char *)&r; + dbuf.dsize = sizeof(r); + tdb_transaction_start(tdb); + tdb_store(tdb, key, dbuf, TDB_REPLACE); + tdb_transaction_commit(tdb); + t = _end_timer(); + ops++; + } while (t < timelimit); + printf("%10.3f ops/sec\n", ops/t); + + ops = 0; printf("Testing traverse speed for %u seconds\n", timelimit); _start_timer(); - while ((t=_end_timer()) < timelimit) { + do { tdb_traverse(tdb, traverse_fn, NULL); - printf("%10.3f ops/sec\r", (++ops)/t); - } - printf("\n"); + t = _end_timer(); + ops++; + } while (t < timelimit); + printf("%10.3f ops/sec\n", ops/t); } static void toggle_mmap(void) |