File: bdbsillytest.cc

package info (click to toggle)
wvstreams 4.0.2-4
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 6,420 kB
  • ctags: 6,518
  • sloc: cpp: 52,544; sh: 5,770; ansic: 810; makefile: 461; tcl: 114; perl: 18
file content (53 lines) | stat: -rw-r--r-- 1,078 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
 * Do some repetitive stuff that *shouldn't* stress bdbhash very much, so
 * that somebody can strace it and see if it does.
 */
#include "wvautoconf.h"

#if defined(WITH_BDB)
#include "wvondiskhash.h"
#include "wvstring.h"

typedef WvOnDiskHash<int, WvString, WvBdbHash> MyHash;

int main()
{
    MyHash h("/tmp/blahdb");
    
    fprintf(stderr, "Zapping...");
    h.zap();
    fprintf(stderr, "done\n");
    
    fprintf(stderr, "Adding...");
    for (int count = 0; count < 1000000; count++)
    {
	h.add(count, WvString("String number %s", count), false);
	//fprintf(stderr, ".");
    }
    fprintf(stderr, "done\n");
#if 0    
    int num = 0;
    MyHash::Iter i(h);
    for (i.rewind(), num = 0; i.next(); num++)
    {
	for (int count = 0; count < 10; count++)
	{
	    int cur = i.key();
	    assert(num == cur);
	    fprintf(stderr, ":");
	    WvString scur(*i);
	    WvString snum("String number %s", num);
	    assert(snum == scur);
	    fprintf(stderr, ".");
	}
	
	fprintf(stderr, "!");
    }
#endif
}
#else
int main(int argc, char *argv[])
{
  return 0;
}
#endif