summaryrefslogtreecommitdiff
path: root/db-4.8.30/test_micro/source/b_curalloc.c
diff options
context:
space:
mode:
authorJesse Morgan <jesse@jesterpm.net>2016-12-17 21:28:53 -0800
committerJesse Morgan <jesse@jesterpm.net>2016-12-17 21:28:53 -0800
commit54df2afaa61c6a03cbb4a33c9b90fa572b6d07b8 (patch)
tree18147b92b969d25ffbe61935fb63035cac820dd0 /db-4.8.30/test_micro/source/b_curalloc.c
Berkeley DB 4.8 with rust build script for linux.
Diffstat (limited to 'db-4.8.30/test_micro/source/b_curalloc.c')
-rw-r--r--db-4.8.30/test_micro/source/b_curalloc.c69
1 files changed, 69 insertions, 0 deletions
diff --git a/db-4.8.30/test_micro/source/b_curalloc.c b/db-4.8.30/test_micro/source/b_curalloc.c
new file mode 100644
index 0000000..410d720
--- /dev/null
+++ b/db-4.8.30/test_micro/source/b_curalloc.c
@@ -0,0 +1,69 @@
+/*
+ * See the file LICENSE for redistribution information.
+ *
+ * Copyright (c) 2005-2009 Oracle. All rights reserved.
+ *
+ * $Id$
+ */
+#include "bench.h"
+
+static int usage(void);
+
+int
+b_curalloc(int argc, char *argv[])
+{
+ extern char *optarg;
+ extern int optind;
+ DB *dbp;
+ DBC *curp;
+ int ch, i, count;
+
+ count = 100000;
+ while ((ch = getopt(argc, argv, "c:")) != EOF)
+ switch (ch) {
+ case 'c':
+ count = atoi(optarg);
+ break;
+ case '?':
+ default:
+ return (usage());
+ }
+ argc -= optind;
+ argv += optind;
+ if (argc != 0)
+ return (usage());
+
+ /* Create the database. */
+ DB_BENCH_ASSERT(db_create(&dbp, NULL, 0) == 0);
+ dbp->set_errfile(dbp, stderr);
+
+#if DB_VERSION_MAJOR >= 4 && DB_VERSION_MINOR >= 1
+ DB_BENCH_ASSERT(dbp->open(
+ dbp, NULL, TESTFILE, NULL, DB_BTREE, DB_CREATE, 0666) == 0);
+#else
+ DB_BENCH_ASSERT(
+ dbp->open(dbp, TESTFILE, NULL, DB_BTREE, DB_CREATE, 0666) == 0);
+#endif
+
+ /* Allocate a cursor count times. */
+ TIMER_START;
+ for (i = 0; i < count; ++i) {
+ DB_BENCH_ASSERT(dbp->cursor(dbp, NULL, &curp, 0) == 0);
+ DB_BENCH_ASSERT(curp->c_close(curp) == 0);
+ }
+ TIMER_STOP;
+
+ printf("# %d cursor allocations\n", count);
+ TIMER_DISPLAY(count);
+
+ DB_BENCH_ASSERT(dbp->close(dbp, 0) == 0);
+
+ return (0);
+}
+
+static int
+usage()
+{
+ (void)fprintf(stderr, "usage: b_curalloc [-c count]\n");
+ return (EXIT_FAILURE);
+}