eXtremeDB新手之Linux平台,BerkeleyDB和eXtremeDB性能在LINUX下的

2022-07-28 00:00:00 专区 订阅 领域 数据管理 实时

BerkeleyDB和eXtremeDB性能在LINUX下的比较

BerkeleyDB和eXtremeDB性能在LINUX下的比较

1、BerkeleyDB测试源程序:

#include

#include #include #include #include

#ifdef _WIN32extern int getopt(int, char * const *, const char *);#else#include #endif

#include "db.h"

extern void __os_clock __P((DB_ENV *, u_int32_t *, u_int32_t *));void usage __P((void));

struct db_time {?u_int32_t secs, usecs;};

struct db_time? start_time, end_time;

u_int32_t? pagesize = 32 * 1024;u_int?? bulkbufsize = 4 * 1024 * 1024;u_int??????????? logbufsize = 8 * 1024 * 1024;u_int??????????? cachesize = 32 * 1024 * 1024;u_int?? datasize = 32;u_int? ? keysize = 8;u_int??????????? 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 (start_time.usecs > end_time.usecs) {??v.secs--;??v.usecs += 1000000;?}?elapsed = v.secs + v.usecs / 1e6;?printf("%s\n\telapsed time: %f seconds : %g key/data pairs per sec\n",???? msg, elapsed, ops / elapsed);}

voidop_ds(u_int ops, int update){?char *letters = "abcdefghijklmnopqrstuvwxuz";?DB *dbp;?DBT key, data;?char *keybuf, *databuf;?DB_MPOOL_STAT? *gsp;

?(void)remove("a");

?assert((keybuf = malloc(keysize)) != NULL);?assert((databuf = malloc(datasize)) != NULL);

?memset(&key, 0, sizeof(key));?memset(&data, 0, sizeof(data));?key.data = keybuf;?key.size = keysize;?memset(keybuf, 'a', keysize);

?data.data = databuf;?data.size = datasize;?memset(databuf, 'b', datasize);

?assert(db_create(&dbp, NULL, 0) == 0);

?dbp->set_errfile(dbp, stderr);

?assert(dbp->set_pagesize(dbp, pagesize) == 0);?assert(dbp->open(dbp, NULL, NULL, NULL, DB_BTREE, DB_CREATE, 0666) == 0);

?dbp->dbenv->memp_stat(dbp->dbenv, &gsp, NULL, DB_STAT_CLEAR);

?if (update) {???????? ??__os_clock(

相关文章