Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2391)

Unified Diff: third_party/leveldatabase/env_chromium_unittest.cc

Issue 2243363002: IndexedDB: Limit the size of a leveldb write buffer to minimize disk space. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Eliminated overloaded WriteBufferSize. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/leveldatabase/env_chromium.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/leveldatabase/env_chromium_unittest.cc
diff --git a/third_party/leveldatabase/env_chromium_unittest.cc b/third_party/leveldatabase/env_chromium_unittest.cc
index d4819e89804399a2235a874de704265070ba03b0..368b24a46c5ce283737feec69f476530f6b1d4a2 100644
--- a/third_party/leveldatabase/env_chromium_unittest.cc
+++ b/third_party/leveldatabase/env_chromium_unittest.cc
@@ -169,4 +169,25 @@ TEST(ChromiumEnv, GetChildrenPriorResults) {
EXPECT_EQ(1U, result.size());
}
+TEST(ChromiumEnv, TestWriteBufferSize) {
+ // If can't get disk size, use leveldb defaults.
+ const int64_t MB = 1024 * 1024;
+ EXPECT_EQ(size_t(4 * MB), leveldb_env::WriteBufferSize(-1));
+
+ // A very small disk (check lower clamp value).
+ EXPECT_EQ(size_t(1 * MB), leveldb_env::WriteBufferSize(1 * MB));
+
+ // Some value on the linear equation between min and max.
+ EXPECT_EQ(size_t(2.5 * MB), leveldb_env::WriteBufferSize(25 * MB));
+
+ // The disk size equating to the max buffer size
+ EXPECT_EQ(size_t(4 * MB), leveldb_env::WriteBufferSize(40 * MB));
+
+ // Make sure sizes larger than 40MB are clamped to max buffer size.
+ EXPECT_EQ(size_t(4 * MB), leveldb_env::WriteBufferSize(80 * MB));
+
+ // Check for very large disk size (catch overflow).
+ EXPECT_EQ(size_t(4 * MB), leveldb_env::WriteBufferSize(100 * MB * MB));
+}
+
int main(int argc, char** argv) { return base::TestSuite(argc, argv).Run(); }
« no previous file with comments | « third_party/leveldatabase/env_chromium.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698