• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /netgear-WNDR4500v2-V1.0.0.60_1.0.38/ap/gpl/timemachine/db-4.7.25.NC/build_vxworks/test_micro/
1/*
2 * $Id: b_curalloc.c,v 1.9 2007/12/21 13:58:30 bostic Exp $
3 */
4#include "bench.h"
5
6static int b_curalloc_usage(void);
7
8int
9b_curalloc(int argc, char *argv[])
10{
11	extern char *optarg;
12	extern int optind, __db_getopt_reset;
13	DB *dbp;
14	DBC *curp;
15	int ch, i, count;
16
17	count = 100000;
18	__db_getopt_reset = 1;
19	while ((ch = getopt(argc, argv, "c:")) != EOF)
20		switch (ch) {
21		case 'c':
22			count = atoi(optarg);
23			break;
24		case '?':
25		default:
26			return (b_curalloc_usage());
27		}
28	argc -= optind;
29	argv += optind;
30	if (argc != 0)
31		return (b_curalloc_usage());
32
33	/* Create the database. */
34	DB_BENCH_ASSERT(db_create(&dbp, NULL, 0) == 0);
35	dbp->set_errfile(dbp, stderr);
36
37#if DB_VERSION_MAJOR >= 4 && DB_VERSION_MINOR >= 1
38	DB_BENCH_ASSERT(dbp->open(
39	    dbp, NULL, TESTFILE, NULL, DB_BTREE, DB_CREATE, 0666) == 0);
40#else
41	DB_BENCH_ASSERT(
42	    dbp->open(dbp, TESTFILE, NULL, DB_BTREE, DB_CREATE, 0666) == 0);
43#endif
44
45	/* Allocate a cursor count times. */
46	TIMER_START;
47	for (i = 0; i < count; ++i) {
48		DB_BENCH_ASSERT(dbp->cursor(dbp, NULL, &curp, 0) == 0);
49		DB_BENCH_ASSERT(curp->c_close(curp) == 0);
50	}
51	TIMER_STOP;
52
53	printf("# %d cursor allocations\n", count);
54	TIMER_DISPLAY(count);
55
56	DB_BENCH_ASSERT(dbp->close(dbp, 0) == 0);
57
58	return (0);
59}
60
61static int
62b_curalloc_usage()
63{
64	(void)fprintf(stderr, "usage: b_curalloc [-c count]\n");
65	return (EXIT_FAILURE);
66}
67