55 #define TEST(fun) { #fun, test_##fun }
60 TEST(GB_find_string_indexed),
69 #define SECOND 1000000
70 #define WANTED_TIME 5*SECOND // time reserved for each test
77 gettimeofday(&t1,
NULp);
78 for (
int i = 0; i<loops; ++i) {
81 gettimeofday(&t2,
NULp);
83 long usecs = t2.tv_sec - t1.tv_sec;
85 usecs += t2.tv_usec - t1.tv_usec;
87 static bool recurse =
true;
94 *perCall = double(usecs)/loops;
116 long duration =
run_test(fun, loops, &perCall);
118 while (duration<1000) {
119 loops = (loops*10000.0)/duration+1;
121 duration =
run_test(fun, loops, &perCall);
126 if (loops <= 0) loops = LONG_MAX;
142 fprintf(stderr,
"arb_perf_test source.arb\n");
143 fprintf(stderr,
"Test performance of some commands - see source code\n");
145 error =
"Missing arguments";
148 const char *in = argv[1];
161 printf(
"Loaded DB '%s'\n", in);
165 printf(
"Running tests:\n");
166 for (
int test = 0; Test[test].
name; ++test) {
171 long usecs =
run_test(Test[test].fun, esti_loops, &perCall);
173 printf(
"Test #%i: %-25s %10li loops = %10li us (%10.2f us/call, %10.2f calls/sec)\n",
187 fprintf(stderr,
"arb_perf_test: Error: %s\n", error);
GBDATA * GB_child(GBDATA *father)
long GBS_write_hash(GB_HASH *hs, const char *key, long val)
static void iterate(GBDATA *gbd)
static GBDATA * gb_species_data
const char * GBS_global_string(const char *templat,...)
static void test_GB_find_string()
GBDATA * GBT_open(const char *path, const char *opent)
GB_ERROR GB_await_error()
static void test_GB_find_string_indexed()
static void error(const char *msg)
static void test_GB_iterate_DB()
GBDATA * GB_find_string(GBDATA *gbd, const char *key, const char *str, GB_CASE case_sens, GB_SEARCH_TYPE gbs)
static long count_elements(GBDATA *gbd)
static long callDelay(long loops)
GBDATA * GB_nextChild(GBDATA *child)
int ARB_main(int argc, char *argv[])
long GBT_get_species_count(GBDATA *gb_main)
GB_transaction ta(gb_var)
static long estimate_loops(test_fun fun)
static long run_test(test_fun fun, long loops, double *perCall)
long GBS_read_hash(const GB_HASH *hs, const char *key)
void GB_close(GBDATA *gbd)
GB_HASH * GBS_create_hash(long estimated_elements, GB_CASE case_sens)
GBDATA * GBT_get_species_data(GBDATA *gb_main)