|
|
@ -35,9 +35,11 @@ static const char* FLAGS_benchmarks = |
|
|
|
"writerandom," |
|
|
|
"writerandom," |
|
|
|
"sync,tenth,tenth,writerandom,nosync,normal," |
|
|
|
"sync,tenth,tenth,writerandom,nosync,normal," |
|
|
|
"readseq," |
|
|
|
"readseq," |
|
|
|
|
|
|
|
"readreverse," |
|
|
|
"readrandom," |
|
|
|
"readrandom," |
|
|
|
"compact," |
|
|
|
"compact," |
|
|
|
"readseq," |
|
|
|
"readseq," |
|
|
|
|
|
|
|
"readreverse," |
|
|
|
"readrandom," |
|
|
|
"readrandom," |
|
|
|
"writebig"; |
|
|
|
"writebig"; |
|
|
|
|
|
|
|
|
|
|
@ -167,7 +169,7 @@ class Benchmark { |
|
|
|
message_.append(rate); |
|
|
|
message_.append(rate); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fprintf(stdout, "%-12s : %10.3f micros/op;%s%s\n", |
|
|
|
fprintf(stdout, "%-12s : %11.3f micros/op;%s%s\n", |
|
|
|
name.ToString().c_str(), |
|
|
|
name.ToString().c_str(), |
|
|
|
(finish - start_) * 1e6 / done_, |
|
|
|
(finish - start_) * 1e6 / done_, |
|
|
|
(message_.empty() ? "" : " "), |
|
|
|
(message_.empty() ? "" : " "), |
|
|
@ -179,7 +181,11 @@ class Benchmark { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public: |
|
|
|
public: |
|
|
|
enum Order { SEQUENTIAL, RANDOM }; |
|
|
|
enum Order { |
|
|
|
|
|
|
|
SEQUENTIAL, |
|
|
|
|
|
|
|
REVERSE, // Currently only supported for reads
|
|
|
|
|
|
|
|
RANDOM |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
Benchmark() : cache_(NewLRUCache(200<<20)), |
|
|
|
Benchmark() : cache_(NewLRUCache(200<<20)), |
|
|
|
db_(NULL), |
|
|
|
db_(NULL), |
|
|
@ -239,6 +245,8 @@ class Benchmark { |
|
|
|
Write(RANDOM, num_ / 1000, 100 * 1000); |
|
|
|
Write(RANDOM, num_ / 1000, 100 * 1000); |
|
|
|
} else if (name == Slice("readseq")) { |
|
|
|
} else if (name == Slice("readseq")) { |
|
|
|
Read(SEQUENTIAL); |
|
|
|
Read(SEQUENTIAL); |
|
|
|
|
|
|
|
} else if (name == Slice("readreverse")) { |
|
|
|
|
|
|
|
Read(REVERSE); |
|
|
|
} else if (name == Slice("readrandom")) { |
|
|
|
} else if (name == Slice("readrandom")) { |
|
|
|
Read(RANDOM); |
|
|
|
Read(RANDOM); |
|
|
|
} else if (name == Slice("compact")) { |
|
|
|
} else if (name == Slice("compact")) { |
|
|
@ -284,23 +292,39 @@ class Benchmark { |
|
|
|
|
|
|
|
|
|
|
|
void Read(Order order) { |
|
|
|
void Read(Order order) { |
|
|
|
ReadOptions options; |
|
|
|
ReadOptions options; |
|
|
|
if (order == SEQUENTIAL) { |
|
|
|
switch (order) { |
|
|
|
Iterator* iter = db_->NewIterator(options); |
|
|
|
case SEQUENTIAL: { |
|
|
|
int i = 0; |
|
|
|
Iterator* iter = db_->NewIterator(options); |
|
|
|
for (iter->SeekToFirst(); i < num_ && iter->Valid(); iter->Next()) { |
|
|
|
int i = 0; |
|
|
|
bytes_ += iter->key().size() + iter->value().size(); |
|
|
|
for (iter->SeekToFirst(); i < num_ && iter->Valid(); iter->Next()) { |
|
|
|
FinishedSingleOp(); |
|
|
|
bytes_ += iter->key().size() + iter->value().size(); |
|
|
|
++i; |
|
|
|
FinishedSingleOp(); |
|
|
|
|
|
|
|
++i; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
delete iter; |
|
|
|
|
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
delete iter; |
|
|
|
case REVERSE: { |
|
|
|
} else { |
|
|
|
Iterator* iter = db_->NewIterator(options); |
|
|
|
std::string value; |
|
|
|
int i = 0; |
|
|
|
for (int i = 0; i < num_; i++) { |
|
|
|
for (iter->SeekToLast(); i < num_ && iter->Valid(); iter->Prev()) { |
|
|
|
char key[100]; |
|
|
|
bytes_ += iter->key().size() + iter->value().size(); |
|
|
|
const int k = (order == SEQUENTIAL) ? i : (rand_.Next() % FLAGS_num); |
|
|
|
FinishedSingleOp(); |
|
|
|
snprintf(key, sizeof(key), "%012d", k); |
|
|
|
++i; |
|
|
|
db_->Get(options, key, &value); |
|
|
|
} |
|
|
|
FinishedSingleOp(); |
|
|
|
delete iter; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
case RANDOM: { |
|
|
|
|
|
|
|
std::string value; |
|
|
|
|
|
|
|
for (int i = 0; i < num_; i++) { |
|
|
|
|
|
|
|
char key[100]; |
|
|
|
|
|
|
|
const int k = (order == SEQUENTIAL) ? i : (rand_.Next() % FLAGS_num); |
|
|
|
|
|
|
|
snprintf(key, sizeof(key), "%012d", k); |
|
|
|
|
|
|
|
db_->Get(options, key, &value); |
|
|
|
|
|
|
|
FinishedSingleOp(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|