1、 numitems = 0;FILE *fp;char*progname;void op_ds(u_int, int);void op_ds_bulk(u_int, u_int *);void op_tds(u_int, int, u_int32_t);void res(char *, u_int);voidres(char *msg, u_int ops)double elapsed;struct db_time v;v.secs = end_time.secs - start_time.secs;v.usecs = end_time.usecs - start_time.usecs;if
2、(start_time.usecs end_time.usecs) v.secs-;v.usecs += 1000000;elapsed = v.secs + v.usecs / 1e6;printf(%sntelapsed time: %f seconds : %g key/data pairs per secn, msg, elapsed, ops / elapsed);op_ds(u_int ops, int update)char *letters = abcdefghijklmnopqrstuvwxuz;DB *dbp;DBT key, data;char *keybuf, *dat
3、abuf;DB_MPOOL_STAT *gsp;(void)remove(a);assert(keybuf = malloc(keysize) != NULL);assert(databuf = malloc(datasize) !memset(&key, 0, sizeof(key);data, 0, sizeof(data);key.data = keybuf;key.size = keysize;memset(keybuf, a, keysize);data.data = databuf;data.size = datasize;memset(databuf, b, datasize);
4、assert(db_create(&dbp, NULL, 0) = 0);dbp-set_errfile(dbp, stderr);assert(dbp-set_pagesize(dbp, pagesize) = 0);open(dbp, NULL, NULL, NULL, DB_BTREE, DB_CREATE, 0666) = 0);dbenv-memp_stat(dbp-dbenv, &gsp, NULL, DB_STAT_CLEAR);if (update) _os_clock(NULL, &start_time.secs, &start_time.usecs);for (; ops
5、0; -ops) keybuf(ops % keysize) = letters(ops % 26);put(dbp, NULL, &key, &data, 0) = 0);end_time.secs, &end_time.usecs); else -ops)get(dbp, NULL, &gsp, NULL, 0);assert(gsp-st_cache_miss = 0);close(dbp, 0) = 0);op_ds_bulk(u_int ops, u_int *totalp)DBC *dbc;u_int32_t len, klen;u_int i, total;void *point
6、er, *dp, *kp;assert(databuf = malloc(bulkbufsize) !set_cachesize(dbp, 0, cachesize, 1) = 0);for (i = 1; i set_msgfile(dbp, fp);assert (dbp-stat_print(dbp, DB_STAT_ALL) = 0);cursor(dbp, NULL, &dbc, 0) = 0);data.ulen = bulkbufsize;data.flags = DB_DBT_USERMEM;if (ops 10000)ops = 10000;for (total = 0;as
7、sert(dbc-c_get( dbc, &data, DB_FIRST | DB_MULTIPLE_KEY) = 0);DB_MULTIPLE_INIT(pointer, &data);while (pointer != NULL) DB_MULTIPLE_KEY_NEXT(pointer, &data, kp, klen, dp, len);if (kp != NULL)+total;*totalp = total;/*assert(dbp-*/op_tds(u_int ops, int update, u_int32_t txn_flags)DB_ENV *dbenv;DB_TXN *t
8、xn;#ifndef _WIN32(void)system(rm -rf TESTDIR; mkdir TESTDIRassert(db_env_create(&dbenv, 0) = 0);set_errfile(dbenv, stderr);assert(dbenv-set_flags(dbenv, DB_AUTO_COMMIT | txn_flags, 1) = 0);set_lg_bsize(dbenv, logbufsize) = 0);open(dbenv, TESTDIR DB_CREATE | DB_PRIVATE | DB_INIT_LOCK | DB_INIT_LOG |
9、DB_INIT_MPOOL | DB_INIT_TXN, 0666) = 0);dbp, dbenv, 0) = 0);open(dbp, NULL, NULL, DB_BTREE, DB_CREATE, 0666) = 0);if (update) memp_stat(dbenv, & -ops)txn_begin(dbenv, NULL, &txn, 0) = 0);assert(txn-commit(txn, 0) = 0);st_page_out = 0);close(dbenv, 0) = 0);intmain(int argc, char *argv)extern char *op
10、targ;extern int optind;u_int ops, total;int ch;int major, minor, patch;if (progname = strrchr(argv0, /) = NULL)progname = argv0;else+progname;ops = 100000;while (ch = getopt(argc, argv, d:k:o:p:) != EOF)switch (ch) case d:datasize = (u_int)atoi(optarg);break;kkeysize = (u_int)atoi(optarg);oops = (u_
11、int)atoi(optarg);ppagesize = (u_int32_t)atoi(optarg);?default:usage();argc -= optind;argv += optind;numitems = (cachesize / (keysize + datasize - 1) / 2;db_version(&major, &minor, &patch);Using Berkeley DB %d.%d.%d - , major, minor, patch);ops: %u; keysize: %d; datasize: %dn, ops, keysize, datasize)
12、;op_ds(ops, 0); res(DS (read):, ops);if (keysize = 8) op_ds_bulk(ops, &total);res(DS (bulk read):, total);ntskipped: bulk get requires a key size = 10nop_ds(ops, 1);DS (write):op_tds(ops, 0, 0);TDS (read):op_tds(ops, 1, DB_LOG_INMEMORY);TDS (write, in-memory logging):op_tds(ops, 1, DB_TXN_NOSYNC);TD
13、S (write, no-sync on commit):op_tds(ops, 1, DB_TXN_WRITE_NOSYNC);TDS (write, write-no-sync on commit):op_tds(ops, 1, 0);TDS (write, sync on commit):return (EXIT_SUCCESS);usage()fprintf(stderr, usage: %s -d datasize -k keysize -o ops -p pagesizen progname);exit(1);2、eXtremeDB测试源程序:/* * Copyright (c)
14、2001-2006 McObject LLC. All Right Reserved.*/* This test allows to receive some results about the eXtremeDB performance* for all basic operations. This test inserts N objects into a class, creating* a hash index as it does insertions; then separatelly builds a tree index,* performs searches using a
15、tree and a hash table, an a sequential search.* At last the tree is removed and all the object are deleted one-by-one.* Each Insetrtion and deletion done in a separate transaction, so the* commit time is included in the measurements.platform.h/#include perf2.h/* Make sure youve got this 16M, otherwi
16、se youll be measuring* the performance of your disk.#define DBSIZE ( 1024 * 16000 )#define PAGESIZE 128const int MAP_ADDRESS = 0x20000000;/* If you change the number of objects inserted, make sure that you* first have enough memory (DBSIZE), and also decalred hash table* size appropriatelly (hkeyestimated_numeber_of_entries in perf2.mcoconst int nRecords = 100000;void _SH_(void) char text = nThis test allows to receive some results about the eXtremeDBnperformance
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1