admin 管理员组

文章数量: 1086019


2024年1月19日发(作者:结束进程显示拒绝访问)

vm6245:~/penjin/leveldb/include # ./te db cost time 0 101.000000(ms) 0.000000(ops)write db cost time 10000 24646.000000(ms) 405745.354216(ops)write db cost time 20000 50850.000000(ms) 393313.667650(ops)write db cost time 30000 77596.000000(ms) 386617.866900(ops)write db cost time 40000 100854.000000(ms) 396612.925615(ops)write db cost time 50000 144434.000000(ms) 346178.877550(ops)write db cost time 60000 294458.000000(ms) 203764.204063(ops)write db cost time 70000 317026.000000(ms) 220802.079325(ops)write db cost time 80000 340610.000000(ms) 234872.728340(ops)write db cost time 90000 520569.000000(ms) 172887.743988(ops)read db cost time 0 36.000000(ms) 0.000000(ops)read db cost time 10000 53165.000000(ms) 188093.670648(ops)read db cost time 20000 88073.000000(ms) 227084.350482(ops)read db cost time 30000 123043.000000(ms) 243817.202116(ops)read db cost time 40000 157281.000000(ms) 254321.882491(ops)read db cost time 50000 191701.000000(ms) 260822.843908(ops)read db cost time 60000 225490.000000(ms) 266087.187902(ops)read db cost time 70000 242869.000000(ms) 288221.222140(ops)read db cost time 80000 261222.000000(ms) 306252.918973(ops)read db cost time 90000 278175.000000(ms) 323537.341602(ops)测试代码如下:

#include#include#include#include"leveldb/db.h"using namespace std;using namespace leveldb;#define TEST_DATA_NUM 100000#define TEST_DATA_LEN 100#define MAX_LEN 10000struct timeval start,current;int main(){ DB *db; Options options; _if_missing = true; //_if_exists = true; Status s = DB::Open(options,"/data/leveldb/",&db); if(!()){ cerr << ng() << endl;exit(-1); } int i; char k[100],v[MAX_LEN+1]; string key,val; for(i = 0;i < MAX_LEN && i < TEST_DATA_LEN ;i ++) { v[i] = 'x'; } v[i] = '0'; val = v; //write db test gettimeofday(&start,NULL); for(i = 0;i < TEST_DATA_NUM; i ++){ snprintf(k,sizeof(k),"key%d",i);

snprintf(k,sizeof(k),"key%d",i); key = k; s = db->Put(WriteOptions(),key,val); if(!()){ cerr << ng() << endl;exit(-1); } if(i % 10000 == 0){ gettimeofday(¤t,NULL); double microsecs = 1000000*(__sec)+(__usec); printf("write db cost time %d %lf(ms) %lf(ops)n",i,microsecs,i/(microsecs/1000000)); }

} //read db test gettimeofday(&start,NULL); for(i = 0;i < TEST_DATA_NUM; i ++){ snprintf(k,sizeof(k),"key%d",i); key = k; s = db->Get(ReadOptions(),key,&val); if(!()){ cerr << ng() << endl;exit(-1); } if(i % 10000 == 0){ gettimeofday(¤t,NULL); double microsecs = 1000000*(__sec)+(__usec); printf("read db cost time %d %lf(ms) %lf(ops)n",i,microsecs,i/(microsecs/1000000)); }

}}


本文标签: 进程 结束 显示