Commit 2b0c0b2a authored by Bradley C. Kuszmaul's avatar Bradley C. Kuszmaul

Clean up scanscan. Addresses #820.

git-svn-id: file:///svn/tokudb@4420 c7de825b-a66e-492c-adef-691d508d4ae1
parent d8917f55
...@@ -59,26 +59,32 @@ double gettime (void) { ...@@ -59,26 +59,32 @@ double gettime (void) {
void scanscan (void) { void scanscan (void) {
int r; int r;
long long totalbytes=0;
double prevtime = gettime();
int counter=0; int counter=0;
while (1) { for (counter=0; counter<2; counter++) {
long long totalbytes=0;
int rowcounter=0;
double prevtime = gettime();
DBT k,v; DBT k,v;
memset(&k, 0, sizeof(k)); memset(&k, 0, sizeof(k));
memset(&v, 0, sizeof(v)); memset(&v, 0, sizeof(v));
r = dbc->c_get(dbc, &k, &v, DB_NEXT); r = dbc->c_get(dbc, &k, &v, DB_FIRST);
if (r==DB_NOTFOUND) { if (r!=DB_NOTFOUND) {
double thistime = gettime(); totalbytes += k.size + v.size;
double tdiff = thistime-prevtime; rowcounter++;
printf("Scan %lld bytes in %9.6fs at %9fMB/s\n", totalbytes, tdiff, 1e-6*totalbytes/tdiff); assert(r==0);
r = dbc->c_get(dbc, &k, &v, DB_FIRST); while (1) {
prevtime = thistime; r = dbc->c_get(dbc, &k, &v, DB_NEXT);
totalbytes=0; if (r==DB_NOTFOUND) {
counter++; break;
if (counter>0) return; }
assert(r==0);
totalbytes += k.size + v.size;
rowcounter++;
}
} }
assert(r==0); double thistime = gettime();
totalbytes += k.size + v.size; double tdiff = thistime-prevtime;
printf("Scan %lld bytes (%d rows) in %9.6fs at %9fMB/s\n", totalbytes, rowcounter, tdiff, 1e-6*totalbytes/tdiff);
} }
} }
...@@ -87,7 +93,6 @@ int main (int argc, char *argv[]) { ...@@ -87,7 +93,6 @@ int main (int argc, char *argv[]) {
argv=argv; argv=argv;
setup(); setup();
scanscan(); scanscan();
scanscan();
shutdown(); shutdown();
return 0; return 0;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment