projects
/
idzebra-moved-to-github.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Added sub modules.
[idzebra-moved-to-github.git]
/
isamb
/
benchisamb.c
diff --git
a/isamb/benchisamb.c
b/isamb/benchisamb.c
index
6b69f6d
..
1773cdf
100644
(file)
--- a/
isamb/benchisamb.c
+++ b/
isamb/benchisamb.c
@@
-1,5
+1,5
@@
-/* $Id: benchisamb.c,v 1.2 2006-12-10 11:49:16 adam Exp $
- Copyright (C) 1995-2006
+/* $Id: benchisamb.c,v 1.6 2007-01-15 15:10:17 adam Exp $
+ Copyright (C) 1995-2007
Index Data ApS
This file is part of the Zebra server.
Index Data ApS
This file is part of the Zebra server.
@@
-32,6
+32,7
@@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include <string.h>
#include <yaz/log.h>
#include <yaz/xmalloc.h>
#include <string.h>
#include <yaz/log.h>
#include <yaz/xmalloc.h>
+#include <yaz/timing.h>
#include <idzebra/isamb.h>
#include <assert.h>
#include <idzebra/isamb.h>
#include <assert.h>
@@
-51,8
+52,8
@@
int compare_item(const void *a, const void *b)
{
int ia, ib;
{
int ia, ib;
- memcpy(&ia, a + 1, sizeof(int));
- memcpy(&ib, b + 1, sizeof(int));
+ memcpy(&ia, (const char *) a + 1, sizeof(int));
+ memcpy(&ib, (const char *) b + 1, sizeof(int));
if (ia > ib)
return 1;
if (ia < ib)
if (ia > ib)
return 1;
if (ia < ib)
@@
-134,22
+135,19
@@
void bench_insert(ISAMB isb, int number_of_trees,
for (round = 0; round < number_of_rounds; round++)
{
for (round = 0; round < number_of_rounds; round++)
{
-#if HAVE_SYS_TIMES_H
-#if HAVE_SYS_TIME_H
- struct tms tms1, tms2;
- struct timeval start_time, end_time;
- double usec;
- times(&tms1);
- gettimeofday(&start_time, 0);
-#endif
-#endif
+ yaz_timing_t t = yaz_timing_create();
+
+ yaz_timing_start(t);
for (i = 0; i<number_of_trees; i++)
{
/* insert a number of entries */
ri.no = 0;
for (i = 0; i<number_of_trees; i++)
{
/* insert a number of entries */
ri.no = 0;
-
+
ri.val = (rand());
ri.val = (rand());
+ if (RAND_MAX < 65536)
+ ri.val = ri.val + 65536*rand();
+
// ri.val = number_of_elements * round;
ri.max = number_of_elements;
// ri.val = number_of_elements * round;
ri.max = number_of_elements;
@@
-161,21
+159,13
@@
void bench_insert(ISAMB isb, int number_of_trees,
if (0)
isamb_dump(isb, isamc_p[i], log_pr);
}
if (0)
isamb_dump(isb, isamc_p[i], log_pr);
}
-#if HAVE_SYS_TIMES_H
-#if HAVE_SYS_TIME_H
- gettimeofday(&end_time, 0);
- times(&tms2);
-
- usec = (end_time.tv_sec - start_time.tv_sec) * 1000000.0 +
- end_time.tv_usec - start_time.tv_usec;
-
+ yaz_timing_stop(t);
printf("%3d %8.6f %5.2f %5.2f\n",
printf("%3d %8.6f %5.2f %5.2f\n",
- round+1,
- usec / 1000000,
- (double) (tms2.tms_utime - tms1.tms_utime)/100,
- (double) (tms2.tms_stime - tms1.tms_stime)/100);
-#endif
-#endif
+ round+1,
+ yaz_timing_get_real(t),
+ yaz_timing_get_user(t),
+ yaz_timing_get_sys(t));
+ yaz_timing_destroy(&t);
}
xfree(isamc_p);
}
}
xfree(isamc_p);
}
@@
-197,7
+187,8
@@
int main(int argc, char **argv)
int number_of_items = 1000;
int number_of_isams = 1000;
int extra_size = 0;
int number_of_items = 1000;
int number_of_isams = 1000;
int extra_size = 0;
-
+ yaz_timing_t t = 0;
+
while ((ret = options("z:r:n:i:", argv, argc, &arg)) != -2)
{
switch(ret)
while ((ret = options("z:r:n:i:", argv, argc, &arg)) != -2)
{
switch(ret)
@@
-232,6
+223,10
@@
int main(int argc, char **argv)
method.codec.reset = code_reset;
method.codec.stop = code_stop;
method.codec.reset = code_reset;
method.codec.stop = code_stop;
+ t = yaz_timing_create();
+
+ yaz_timing_start(t);
+
/* create block system */
bfs = bfs_create(0, 0);
if (!bfs)
/* create block system */
bfs = bfs_create(0, 0);
if (!bfs)
@@
-256,6
+251,13
@@
int main(int argc, char **argv)
/* exit block system */
bfs_destroy(bfs);
/* exit block system */
bfs_destroy(bfs);
+
+ yaz_timing_stop(t);
+ printf("Total %8.6f %5.2f %5.2f\n",
+ yaz_timing_get_real(t),
+ yaz_timing_get_user(t),
+ yaz_timing_get_sys(t));
+ yaz_timing_destroy(&t);
exit(0);
return 0;
}
exit(0);
return 0;
}