mirror of
https://github.com/google/leveldb.git
synced 2026-08-22 10:53:27 +08:00
C binding for leveldb, better readseq benchmark for SQLite.
- Added a C binding for LevelDB. May be useful as a stable ABI that can be used by programs that keep leveldb in a shared library, or for JNI API. - Replaced SQLite's readseq benchmark to a more efficient version. SQLite readseq speeds increased by about a factor of 2x from the previous version. Also updated benchmark page to reflect readseq speed up. git-svn-id: https://leveldb.googlecode.com/svn/trunk@46 62dab493-f737-651d-591e-8d6aee1b9529
This commit is contained in:
@@ -23,7 +23,6 @@
|
||||
// fillseq100K -- write N/1000 100K values in sequential order in async mode
|
||||
// readseq -- read N times sequentially
|
||||
// readrandom -- read N times in random order
|
||||
// readseq100K -- read N/1000 100K values in sequential order in async mode
|
||||
// readrand100K -- read N/1000 100K values in sequential order in async mode
|
||||
static const char* FLAGS_benchmarks =
|
||||
"fillseq,"
|
||||
@@ -38,7 +37,7 @@ static const char* FLAGS_benchmarks =
|
||||
"readseq,"
|
||||
"fillrand100K,"
|
||||
"fillseq100K,"
|
||||
"readseq100K,"
|
||||
"readseq,"
|
||||
"readrand100K,"
|
||||
;
|
||||
|
||||
@@ -387,7 +386,7 @@ class Benchmark {
|
||||
Write(write_sync, SEQUENTIAL, FRESH, num_ / 1000, 100 * 1000, 1);
|
||||
WalCheckpoint(db_);
|
||||
} else if (name == Slice("readseq")) {
|
||||
Read(SEQUENTIAL, 1);
|
||||
ReadSequential();
|
||||
} else if (name == Slice("readrandom")) {
|
||||
Read(RANDOM, 1);
|
||||
} else if (name == Slice("readrand100K")) {
|
||||
@@ -395,11 +394,6 @@ class Benchmark {
|
||||
reads_ /= 1000;
|
||||
Read(RANDOM, 1);
|
||||
reads_ = n;
|
||||
} else if (name == Slice("readseq100K")) {
|
||||
int n = reads_;
|
||||
reads_ /= 1000;
|
||||
Read(SEQUENTIAL, 1);
|
||||
reads_ = n;
|
||||
} else {
|
||||
known = false;
|
||||
if (name != Slice()) { // No error message for empty name
|
||||
@@ -640,6 +634,22 @@ class Benchmark {
|
||||
ErrorCheck(status);
|
||||
}
|
||||
|
||||
void ReadSequential() {
|
||||
int status;
|
||||
sqlite3_stmt *pStmt;
|
||||
std::string read_str = "SELECT * FROM test ORDER BY key";
|
||||
|
||||
status = sqlite3_prepare_v2(db_, read_str.c_str(), -1, &pStmt, NULL);
|
||||
ErrorCheck(status);
|
||||
for (int i = 0; i < reads_ && SQLITE_ROW == sqlite3_step(pStmt); i++) {
|
||||
bytes_ += sqlite3_column_bytes(pStmt, 1) + sqlite3_column_bytes(pStmt, 2);
|
||||
FinishedSingleOp();
|
||||
}
|
||||
|
||||
status = sqlite3_finalize(pStmt);
|
||||
ErrorCheck(status);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user