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

Unified Diff: chrome/test/live_sync/performance_live_bookmarks_sync_test.cc

Issue 7171003: Performance tests for bookmark sync. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Missing comments + extra refactoring Created 9 years, 6 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
Index: chrome/test/live_sync/performance_live_bookmarks_sync_test.cc
diff --git a/chrome/test/live_sync/performance_live_bookmarks_sync_test.cc b/chrome/test/live_sync/performance_live_bookmarks_sync_test.cc
new file mode 100644
index 0000000000000000000000000000000000000000..7dd0768be35fa8d4be27892ad9cc746267c1ab50
--- /dev/null
+++ b/chrome/test/live_sync/performance_live_bookmarks_sync_test.cc
@@ -0,0 +1,233 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+/*
+#include "base/time.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/sync/profile_sync_service_harness.h"
+#include "chrome/test/live_sync/live_bookmarks_sync_test.h"
+*/
Raghu Simha 2011/06/16 22:42:55 Remove this block if it's unnecessary.
braffert 2011/06/17 18:19:46 Done.
+
+#include "chrome/browser/sync/profile_sync_service_harness.h"
+#include "chrome/test/live_sync/live_bookmarks_sync_test.h"
+#include "chrome/test/live_sync/live_sync_timing_helper.h"
+
+static const int kNumBookmarks = 150;
+
+// TODO(braffert): Consider the range / resolution of these test points.
+static const int kNumBenchmarkPoints = 18;
+static const int kBenchmarkPoints[] = {1, 10, 20, 30, 40, 50, 75, 100, 125,
+ 150, 175, 200, 225, 250, 300, 350, 400,
+ 500};
+
+// TODO(braffert): Move this class into its own .h/.cc files. What should the
+// class files be named as opposed to the file containing the tests themselves?
Raghu Simha 2011/06/16 22:42:55 How about naming the class LiveBookmarksSyncPerfor
+class PerformanceLiveBookmarksSyncTest
+ : public TwoClientLiveBookmarksSyncTest {
+ public:
+ PerformanceLiveBookmarksSyncTest() : urlNumber(0), urlTitleNumber(0) {}
+
+ // Pairs the test class with the timer helper for measuring sync times.
+ void SetUp() OVERRIDE;
Raghu Simha 2011/06/16 22:42:55 With the change I've suggested to LiveSyncTimingHe
braffert 2011/06/17 18:19:46 Done.
+
+ // Adds |nURLs| new unique bookmarks to the bookmark bar for |profile|.
+ void AddURLs(int profile, int nURLs);
Raghu Simha 2011/06/16 22:42:55 Style guide recommends num_urls over nURLs.
braffert 2011/06/17 18:19:46 Done.
+
+ // Updates the URL for all bookmarks in the bookmark bar for |profile|.
+ void UpdateURLs(int profile);
+
+ // Removes all bookmarks in the bookmark bar for |profile|.
+ void RemoveURLs(int profile);
+
+ // Remvoes all bookmarks in the bookmark bars for all profiles. Called
+ // between benchmark iterations.
+ void Cleanup();
+
+ LiveSyncTimingHelper timing_helper;
Raghu Simha 2011/06/16 22:42:55 With the change I've suggested to LiveSyncTimingHe
braffert 2011/06/17 18:19:46 Done.
+
+ private:
+ // Returns a new unique bookmark URL.
+ GURL NextIndexedURL();
Raghu Simha 2011/06/16 22:42:55 IndexedURL returns a wstring while NextIndexedURL
braffert 2011/06/17 18:19:46 Taking the easy option here - just to keep this CL
+
+ // Returns a new unique bookmark title.
+ std::wstring NextIndexedURLTitle();
+
+ int urlNumber;
Raghu Simha 2011/06/16 22:42:55 Style guide recommends that variable names are low
braffert 2011/06/17 18:19:46 Done.
+ int urlTitleNumber;
+ DISALLOW_COPY_AND_ASSIGN(PerformanceLiveBookmarksSyncTest);
+};
+
+void PerformanceLiveBookmarksSyncTest::SetUp() {
+ timing_helper.Setup(this);
+ LiveSyncTest::SetUp();
+}
+
+void PerformanceLiveBookmarksSyncTest::AddURLs(int profile, int nURLs) {
+ for (int i = 0; i < nURLs; ++i) {
+ ASSERT_TRUE(AddURL(
+ profile, 0, NextIndexedURLTitle(), NextIndexedURL()) != NULL);
+ }
+}
+
+void PerformanceLiveBookmarksSyncTest::UpdateURLs(int profile) {
+ for (int i = 0; i < GetBookmarkBarNode(profile)->child_count(); ++i) {
+ ASSERT_TRUE(SetURL(profile, GetBookmarkBarNode(profile)->GetChild(i),
+ NextIndexedURL()));
+ }
+}
+
+void PerformanceLiveBookmarksSyncTest::RemoveURLs(int profile) {
+ while (GetBookmarkBarNode(profile)->child_count()) {
+ Remove(profile, GetBookmarkBarNode(profile), 0);
+ }
+}
+
+void PerformanceLiveBookmarksSyncTest::Cleanup() {
+ for (int i = 0; i < num_clients(); ++i) {
+ RemoveURLs(i);
+ }
+ ASSERT_TRUE(AwaitQuiescence());
+ ASSERT_EQ(0, GetBookmarkBarNode(0)->child_count());
+ ASSERT_TRUE(AllModelsMatch());
+}
+
+GURL PerformanceLiveBookmarksSyncTest::NextIndexedURL() {
+ return GURL(IndexedURL(urlNumber++));
+}
+
+std::wstring PerformanceLiveBookmarksSyncTest::NextIndexedURLTitle() {
+ return IndexedURLTitle(urlTitleNumber++);
+}
+
+// TODO(braffert): Possibly split each of these into separate up / down test
+// cases?
+IN_PROC_BROWSER_TEST_F(PerformanceLiveBookmarksSyncTest, Add) {
+ ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
+ DisableVerifier();
+
+ DisableNetwork(GetProfile(1));
+ AddURLs(0, kNumBookmarks);
+ base::TimeDelta dt_up = timing_helper.TimeSyncCycle(GetClient(0));
+ ASSERT_EQ(kNumBookmarks, GetBookmarkBarNode(0)->child_count());
+ ASSERT_EQ(0, GetBookmarkBarNode(1)->child_count());
+
+ EnableNetwork(GetProfile(1));
+ base::TimeDelta dt_down = timing_helper.TimeMutualSyncCycle(GetClient(0),
+ GetClient(1));
+ ASSERT_EQ(kNumBookmarks, GetBookmarkBarNode(0)->child_count());
+ ASSERT_TRUE(AllModelsMatch());
+
+ // TODO(braffert): Compare timings against some target value.
+}
+
+IN_PROC_BROWSER_TEST_F(PerformanceLiveBookmarksSyncTest, Update) {
+ ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
+ DisableVerifier();
+
+ AddURLs(0, kNumBookmarks);
+ ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
+ ASSERT_TRUE(AllModelsMatch());
+
+ DisableNetwork(GetProfile(1));
+ UpdateURLs(0);
+ base::TimeDelta dt_up = timing_helper.TimeSyncCycle(GetClient(0));
+ ASSERT_EQ(kNumBookmarks, GetBookmarkBarNode(0)->child_count());
+ ASSERT_EQ(kNumBookmarks, GetBookmarkBarNode(1)->child_count());
+ ASSERT_FALSE(AllModelsMatch());
+
+ EnableNetwork(GetProfile(1));
+ base::TimeDelta dt_down = timing_helper.TimeMutualSyncCycle(GetClient(0),
+ GetClient(1));
+ ASSERT_EQ(kNumBookmarks, GetBookmarkBarNode(0)->child_count());
+ ASSERT_EQ(kNumBookmarks, GetBookmarkBarNode(1)->child_count());
+
+ // TODO(braffert): Compare timings against some target value.
+}
+
+IN_PROC_BROWSER_TEST_F(PerformanceLiveBookmarksSyncTest, Delete) {
+ ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
+ DisableVerifier();
+
+ AddURLs(0, kNumBookmarks);
+ ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
+ ASSERT_TRUE(AllModelsMatch());
+
+ DisableNetwork(GetProfile(1));
+ RemoveURLs(0);
+ base::TimeDelta dt_up = timing_helper.TimeSyncCycle(GetClient(0));
+ ASSERT_EQ(0, GetBookmarkBarNode(0)->child_count());
+ ASSERT_EQ(kNumBookmarks, GetBookmarkBarNode(1)->child_count());
+
+ EnableNetwork(GetProfile(1));
+ base::TimeDelta dt_down = timing_helper.TimeMutualSyncCycle(GetClient(0),
+ GetClient(1));
+ ASSERT_EQ(0, GetBookmarkBarNode(0)->child_count());
+ ASSERT_EQ(0, GetBookmarkBarNode(1)->child_count());
+
+ // TODO(braffert): Compare timings against some target value.
+}
+
+IN_PROC_BROWSER_TEST_F(PerformanceLiveBookmarksSyncTest, Benchmark) {
+ ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
+ DisableVerifier();
+
+ for (int i = 0; i < kNumBenchmarkPoints; ++i) {
+ int numBookmarks = kBenchmarkPoints[i];
Raghu Simha 2011/06/16 22:42:55 numBookmarks -> num_bookmarks.
braffert 2011/06/17 18:19:46 Done. Curious - why do constants use a different
+
+ // Disable client 1. Add bookmarks and time commit by client 0.
+ DisableNetwork(GetProfile(1));
+ AddURLs(0, numBookmarks);
+ base::TimeDelta dt_up = timing_helper.TimeSyncCycle(GetClient(0));
+ ASSERT_EQ(numBookmarks, GetBookmarkBarNode(0)->child_count());
+ ASSERT_EQ(0, GetBookmarkBarNode(1)->child_count());
+
+ // Enable client 1 and time update (new bookmarks).
+ EnableNetwork(GetProfile(1));
+ base::TimeDelta dt_down = timing_helper.TimeMutualSyncCycle(GetClient(0),
+ GetClient(1));
+ ASSERT_EQ(numBookmarks, GetBookmarkBarNode(0)->child_count());
+ ASSERT_TRUE(AllModelsMatch());
+
+ VLOG(0) << std::endl << "Add: " << numBookmarks << " " <<
+ static_cast<double>(numBookmarks) / dt_up.InSecondsF() << " " <<
+ static_cast<double>(numBookmarks) / dt_down.InSecondsF();
+
+ // Disable client 1. Modify bookmarks and time commit by client 0.
+ DisableNetwork(GetProfile(1));
+ UpdateURLs(0);
+ dt_up = timing_helper.TimeSyncCycle(GetClient(0));
+ ASSERT_EQ(numBookmarks, GetBookmarkBarNode(0)->child_count());
+ ASSERT_EQ(numBookmarks, GetBookmarkBarNode(1)->child_count());
+ ASSERT_FALSE(AllModelsMatch());
+
+ // Enable client 1 and time update (changed bookmarks).
+ EnableNetwork(GetProfile(1));
+ dt_down = timing_helper.TimeMutualSyncCycle(GetClient(0), GetClient(1));
+ ASSERT_EQ(numBookmarks, GetBookmarkBarNode(0)->child_count());
+ ASSERT_TRUE(AllModelsMatch());
+
+ VLOG(0) << std::endl << "Update: " << numBookmarks << " " <<
+ static_cast<double>(numBookmarks) / dt_up.InSecondsF() << " " <<
+ static_cast<double>(numBookmarks) / dt_down.InSecondsF();
+
+ // Disable client 1. Delete bookmarks and time commit by client 0.
+ DisableNetwork(GetProfile(1));
+ RemoveURLs(0);
+ dt_up = timing_helper.TimeSyncCycle(GetClient(0));
+ ASSERT_EQ(0, GetBookmarkBarNode(0)->child_count());
+ ASSERT_EQ(numBookmarks, GetBookmarkBarNode(1)->child_count());
+
+ // Enable client 1 and time update (deleted bookmarks).
+ EnableNetwork(GetProfile(1));
+ dt_down = timing_helper.TimeMutualSyncCycle(GetClient(0), GetClient(1));
+ ASSERT_EQ(0, GetBookmarkBarNode(0)->child_count());
+ ASSERT_EQ(0, GetBookmarkBarNode(1)->child_count());
+
+ VLOG(0) << std::endl << "Delete: " << numBookmarks << " " <<
+ static_cast<double>(numBookmarks) / dt_up.InSecondsF() << " " <<
+ static_cast<double>(numBookmarks) / dt_down.InSecondsF();
+
+ Cleanup();
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698