------------------------------------------------------------
revno: 750
revision-id:[EMAIL PROTECTED]
parent: [EMAIL PROTECTED]
committer: Andrew Tridgell <[EMAIL PROTECTED]>
branch nick: tridge.stable
timestamp: Wed 2008-01-09 17:45:13 +1100
message:
report the store rate in ctdb_randrec
modified:
tests/ctdb_randrec.c
ctdb_randrec.c-20080103224053-3pf5tyxleld8dqam-1
=== modified file 'tests/ctdb_randrec.c'
--- a/tests/ctdb_randrec.c 2008-01-09 04:32:18 +0000
+++ b/tests/ctdb_randrec.c 2008-01-09 06:45:13 +0000
@@ -27,6 +27,20 @@
#include <sys/time.h>
#include <time.h>
+static struct timeval tp1,tp2;
+
+static void start_timer(void)
+{
+ gettimeofday(&tp1,NULL);
+}
+
+static double end_timer(void)
+{
+ gettimeofday(&tp2,NULL);
+ return (tp2.tv_sec + (tp2.tv_usec*1.0e-6)) -
+ (tp1.tv_sec + (tp1.tv_usec*1.0e-6));
+}
+
static int num_records = 10;
static int delete_pct = 75;
static int base_rec;
@@ -44,6 +58,8 @@
srandom(time(NULL) ^ getpid());
+ start_timer();
+
printf("working with %d records\n", num_records);
while (1) {
unsigned r = random() % num_records;
@@ -72,8 +88,9 @@
printf("Failed to store record\n");
}
if (i % 1000 == 0) {
- printf("%u\r", i);
+ printf("%7.0f recs/second %u total\r", 1000.0 /
end_timer(), i);
fflush(stdout);
+ start_timer();
}
i++;
}