Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

[88c706]: db / db-test.c Maximize Restore History

Download this file

db-test.c    59 lines (46 with data), 1.0 kB

 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
54
55
56
57
58
#include <sys/resource.h>
//#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include "db.h"
static double user_time()
{
struct rusage usage;
getrusage(RUSAGE_SELF, &usage);
return usage.ru_utime.tv_sec + (usage.ru_utime.tv_usec / 1000000.0);
}
int main()
{
int i;
double begin, end;
root_t root;
init_root(&root);
#if 0
insert(&root, 16, 1);
insert(&root, 32, 1);
insert(&root, 48, 1);
insert(&root, 64, 1);
insert(&root, 80, 1);
insert(&root, 96, 1);
insert(&root, 100, 1);
insert(&root, 9, 1);
// insert(&root, 11, 1);
// insert(&root, 13, 1);
// insert(&root, 1, 1);
#else
begin = user_time();
for (i = 0 ; i < 1000000 ; ++i) {
insert(&root, random() % 10000, 1);
}
end = user_time();
fprintf(stderr, "%f\n", end - begin);
#endif
if (check_tree(&root, root.root, 0u))
fprintf(stderr, "test failure\n");
else
fprintf(stderr, "test ok\n");
// recursively travel in the btree and check than all thing are right
// display_tree(&root, root.root);
delete_root(&root);
return 0;
}