diff options
author | costan <costan@google.com> | 2017-05-23 17:29:44 -0700 |
---|---|---|
committer | Victor Costan <pwnall@chromium.org> | 2017-07-10 14:13:30 -0700 |
commit | 69e2bd224b7f11e021527cb95bab18f1ee6e1b3b (patch) | |
tree | badd275cd7f6997294f84d6636a5309369933d81 /db/write_batch_test.cc | |
parent | a53934a3ae1244679f812d998a4f16f2c7f309a6 (diff) | |
download | leveldb-69e2bd224b7f11e021527cb95bab18f1ee6e1b3b.tar.gz |
LevelDB: Add WriteBatch::ApproximateSize().
This can be used to report metrics on LevelDB usage.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=156934930
Diffstat (limited to 'db/write_batch_test.cc')
-rw-r--r-- | db/write_batch_test.cc | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/db/write_batch_test.cc b/db/write_batch_test.cc index 9064e3d..8d38023 100644 --- a/db/write_batch_test.cc +++ b/db/write_batch_test.cc @@ -113,6 +113,23 @@ TEST(WriteBatchTest, Append) { PrintContents(&b1)); } +TEST(WriteBatchTest, ApproximateSize) { + WriteBatch batch; + size_t empty_size = batch.ApproximateSize(); + + batch.Put(Slice("foo"), Slice("bar")); + size_t one_key_size = batch.ApproximateSize(); + ASSERT_LT(empty_size, one_key_size); + + batch.Put(Slice("baz"), Slice("boo")); + size_t two_keys_size = batch.ApproximateSize(); + ASSERT_LT(one_key_size, two_keys_size); + + batch.Delete(Slice("box")); + size_t post_delete_size = batch.ApproximateSize(); + ASSERT_LT(two_keys_size, post_delete_size); +} + } // namespace leveldb int main(int argc, char** argv) { |