Commit 85043a91 authored by braffert@chromium.org's avatar braffert@chromium.org

Sync performance tests: take timings with autofill keys in addition to profiles.

This patch extends the existing AutofillSyncPerfTest class to also measure add and
delete time for autofill keys.  Updating an individual autofill key is not possible,
as far as I can tell.

BUG=none
TEST=sync_performance_tests


Review URL: http://codereview.chromium.org/7590007

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@96304 0039d316-1c4b-4281-b951-d872f2087c98
parent 5b0ec7ff
...@@ -130,8 +130,7 @@ PersonalDataManager* GetPersonalDataManager(int index) { ...@@ -130,8 +130,7 @@ PersonalDataManager* GetPersonalDataManager(int index) {
return test()->GetProfile(index)->GetPersonalDataManager(); return test()->GetProfile(index)->GetPersonalDataManager();
} }
void AddKeys(int profile, void AddKeys(int profile, const std::set<AutofillKey>& keys) {
const std::set<AutofillKey>& keys) {
std::vector<webkit_glue::FormField> form_fields; std::vector<webkit_glue::FormField> form_fields;
for (std::set<AutofillKey>::const_iterator i = keys.begin(); for (std::set<AutofillKey>::const_iterator i = keys.begin();
i != keys.end(); i != keys.end();
...@@ -246,6 +245,10 @@ int GetProfileCount(int profile) { ...@@ -246,6 +245,10 @@ int GetProfileCount(int profile) {
return GetAllProfiles(profile).size(); return GetAllProfiles(profile).size();
} }
int GetKeyCount(int profile) {
return GetAllKeys(profile).size();
}
bool ProfilesMatch(int profile_a, int profile_b) { bool ProfilesMatch(int profile_a, int profile_b) {
const std::vector<AutofillProfile*>& autofill_profiles_a = const std::vector<AutofillProfile*>& autofill_profiles_a =
GetAllProfiles(profile_a); GetAllProfiles(profile_a);
......
...@@ -78,6 +78,9 @@ const std::vector<AutofillProfile*>& GetAllProfiles( ...@@ -78,6 +78,9 @@ const std::vector<AutofillProfile*>& GetAllProfiles(
// |profile|. // |profile|.
int GetProfileCount(int profile); int GetProfileCount(int profile);
// Returns the number of autofill keys contained by sync profile |profile|.
int GetKeyCount(int profile);
// Compares the Autofill profiles in the PersonalDataManagers of sync profiles // Compares the Autofill profiles in the PersonalDataManagers of sync profiles
// |profile_a| and |profile_b|. Returns true if they match. // |profile_a| and |profile_b|. Returns true if they match.
bool ProfilesMatch(int profile_a, int profile_b) WARN_UNUSED_RESULT; bool ProfilesMatch(int profile_a, int profile_b) WARN_UNUSED_RESULT;
......
...@@ -7,17 +7,22 @@ ...@@ -7,17 +7,22 @@
#include "chrome/browser/autofill/autofill_common_test.h" #include "chrome/browser/autofill/autofill_common_test.h"
#include "chrome/browser/autofill/autofill_profile.h" #include "chrome/browser/autofill/autofill_profile.h"
#include "chrome/browser/sync/profile_sync_service_harness.h" #include "chrome/browser/sync/profile_sync_service_harness.h"
#include "chrome/browser/webdata/autofill_entry.h"
#include "chrome/test/live_sync/autofill_helper.h" #include "chrome/test/live_sync/autofill_helper.h"
#include "chrome/test/live_sync/live_sync_test.h" #include "chrome/test/live_sync/live_sync_test.h"
#include "chrome/test/live_sync/performance/sync_timing_helper.h" #include "chrome/test/live_sync/performance/sync_timing_helper.h"
using autofill_helper::AllProfilesMatch; using autofill_helper::AllProfilesMatch;
using autofill_helper::GetAllKeys;
using autofill_helper::GetAllProfiles; using autofill_helper::GetAllProfiles;
using autofill_helper::GetKeyCount;
using autofill_helper::GetProfileCount; using autofill_helper::GetProfileCount;
using autofill_helper::RemoveKey;
using autofill_helper::SetProfiles; using autofill_helper::SetProfiles;
// TODO(braffert): Move kNumBenchmarkPoints and kBenchmarkPoints for all // TODO(braffert): Move kNumBenchmarkPoints and kBenchmarkPoints for all
// datatypes into a performance test base class, once it is possible to do so. // datatypes into a performance test base class, once it is possible to do so.
static const int kNumKeys = 150;
static const int kNumProfiles = 150; static const int kNumProfiles = 150;
static const int kNumBenchmarkPoints = 18; static const int kNumBenchmarkPoints = 18;
static const int kBenchmarkPoints[] = {1, 10, 20, 30, 40, 50, 75, 100, 125, static const int kBenchmarkPoints[] = {1, 10, 20, 30, 40, 50, 75, 100, 125,
...@@ -29,7 +34,8 @@ class AutofillSyncPerfTest : public LiveSyncTest { ...@@ -29,7 +34,8 @@ class AutofillSyncPerfTest : public LiveSyncTest {
AutofillSyncPerfTest() AutofillSyncPerfTest()
: LiveSyncTest(TWO_CLIENT), : LiveSyncTest(TWO_CLIENT),
guid_number_(0), guid_number_(0),
name_number_(0) {} name_number_(0),
value_number_(0) {}
// Adds |num_profiles| new autofill profiles to the sync profile |profile|. // Adds |num_profiles| new autofill profiles to the sync profile |profile|.
void AddProfiles(int profile, int num_profiles); void AddProfiles(int profile, int num_profiles);
...@@ -37,9 +43,15 @@ class AutofillSyncPerfTest : public LiveSyncTest { ...@@ -37,9 +43,15 @@ class AutofillSyncPerfTest : public LiveSyncTest {
// Updates all autofill profiles for the sync profile |profile|. // Updates all autofill profiles for the sync profile |profile|.
void UpdateProfiles(int profile); void UpdateProfiles(int profile);
// Removes all bookmarks in the bookmark bar for |profile|. // Removes all autofill profiles from |profile|.
void RemoveProfiles(int profile); void RemoveProfiles(int profile);
// Adds |num_keys| new autofill keys to the sync profile |profile|.
void AddKeys(int profile, int num_keys);
// Removes all autofill keys from |profile|.
void RemoveKeys(int profile);
// Removes all autofill profiles in all sync profiles. Called between // Removes all autofill profiles in all sync profiles. Called between
// benchmark iterations. // benchmark iterations.
void Cleanup(); void Cleanup();
...@@ -48,6 +60,9 @@ class AutofillSyncPerfTest : public LiveSyncTest { ...@@ -48,6 +60,9 @@ class AutofillSyncPerfTest : public LiveSyncTest {
// Returns a new unique autofill profile. // Returns a new unique autofill profile.
const AutofillProfile NextAutofillProfile(); const AutofillProfile NextAutofillProfile();
// Returns a new unique autofill key.
const AutofillKey NextAutofillKey();
// Returns an unused unique guid. // Returns an unused unique guid.
const std::string NextGUID(); const std::string NextGUID();
...@@ -60,8 +75,15 @@ class AutofillSyncPerfTest : public LiveSyncTest { ...@@ -60,8 +75,15 @@ class AutofillSyncPerfTest : public LiveSyncTest {
// Returns a unique name based on the input integer |n|. // Returns a unique name based on the input integer |n|.
const std::string IntToName(int n); const std::string IntToName(int n);
// Returns a new unused unique value for autofill entries.
const std::string NextValue();
// Returnes a unique value based on the input integer |n|.
const std::string IntToValue(int n);
int guid_number_; int guid_number_;
int name_number_; int name_number_;
int value_number_;
DISALLOW_COPY_AND_ASSIGN(AutofillSyncPerfTest); DISALLOW_COPY_AND_ASSIGN(AutofillSyncPerfTest);
}; };
...@@ -95,6 +117,22 @@ void AutofillSyncPerfTest::RemoveProfiles(int profile) { ...@@ -95,6 +117,22 @@ void AutofillSyncPerfTest::RemoveProfiles(int profile) {
SetProfiles(profile, &empty); SetProfiles(profile, &empty);
} }
void AutofillSyncPerfTest::AddKeys(int profile, int num_keys) {
std::set<AutofillKey> keys;
for (int i = 0; i < num_keys; ++i) {
keys.insert(NextAutofillKey());
}
autofill_helper::AddKeys(profile, keys);
}
void AutofillSyncPerfTest::RemoveKeys(int profile) {
std::set<AutofillEntry> keys = GetAllKeys(profile);
for (std::set<AutofillEntry>::const_iterator it = keys.begin();
it != keys.end(); ++it) {
RemoveKey(profile, it->key());
}
}
void AutofillSyncPerfTest::Cleanup() { void AutofillSyncPerfTest::Cleanup() {
for (int i = 0; i < num_clients(); ++i) { for (int i = 0; i < num_clients(); ++i) {
RemoveProfiles(i); RemoveProfiles(i);
...@@ -110,6 +148,10 @@ const AutofillProfile AutofillSyncPerfTest::NextAutofillProfile() { ...@@ -110,6 +148,10 @@ const AutofillProfile AutofillSyncPerfTest::NextAutofillProfile() {
return profile; return profile;
} }
const AutofillKey AutofillSyncPerfTest::NextAutofillKey() {
return AutofillKey(NextName().c_str(), NextName().c_str());
}
const std::string AutofillSyncPerfTest::NextGUID() { const std::string AutofillSyncPerfTest::NextGUID() {
return IntToGUID(guid_number_++); return IntToGUID(guid_number_++);
} }
...@@ -123,10 +165,18 @@ const std::string AutofillSyncPerfTest::NextName() { ...@@ -123,10 +165,18 @@ const std::string AutofillSyncPerfTest::NextName() {
} }
const std::string AutofillSyncPerfTest::IntToName(int n) { const std::string AutofillSyncPerfTest::IntToName(int n) {
return StringPrintf("Name%d" , n); return StringPrintf("Name%d", n);
} }
IN_PROC_BROWSER_TEST_F(AutofillSyncPerfTest, P0) { const std::string AutofillSyncPerfTest::NextValue() {
return IntToValue(value_number_++);
}
const std::string AutofillSyncPerfTest::IntToValue(int n) {
return StringPrintf("Value%d", n);
}
IN_PROC_BROWSER_TEST_F(AutofillSyncPerfTest, AutofillProfiles_P0) {
ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
// TCM ID - 7557873. // TCM ID - 7557873.
...@@ -134,19 +184,34 @@ IN_PROC_BROWSER_TEST_F(AutofillSyncPerfTest, P0) { ...@@ -134,19 +184,34 @@ IN_PROC_BROWSER_TEST_F(AutofillSyncPerfTest, P0) {
base::TimeDelta dt = base::TimeDelta dt =
SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1));
ASSERT_EQ(kNumProfiles, GetProfileCount(1)); ASSERT_EQ(kNumProfiles, GetProfileCount(1));
SyncTimingHelper::PrintResult("autofill", "add", dt); SyncTimingHelper::PrintResult("autofill", "add_autofill_profiles", dt);
// TCM ID - 7549835. // TCM ID - 7549835.
UpdateProfiles(0); UpdateProfiles(0);
dt = SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); dt = SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1));
ASSERT_EQ(kNumProfiles, GetProfileCount(1)); ASSERT_EQ(kNumProfiles, GetProfileCount(1));
SyncTimingHelper::PrintResult("autofill", "update", dt); SyncTimingHelper::PrintResult("autofill", "update_autofill_profiles", dt);
// TCM ID - 7553678. // TCM ID - 7553678.
RemoveProfiles(0); RemoveProfiles(0);
dt = SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); dt = SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1));
ASSERT_EQ(0, GetProfileCount(1)); ASSERT_EQ(0, GetProfileCount(1));
SyncTimingHelper::PrintResult("autofill", "delete", dt); SyncTimingHelper::PrintResult("autofill", "delete_autofill_profiles", dt);
}
IN_PROC_BROWSER_TEST_F(AutofillSyncPerfTest, Autofill_P0) {
ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
AddKeys(0, kNumKeys);
base::TimeDelta dt =
SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1));
ASSERT_EQ(kNumKeys, GetKeyCount(1));
SyncTimingHelper::PrintResult("autofill", "add_autofill_keys", dt);
RemoveKeys(0);
dt = SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1));
ASSERT_EQ(0, GetKeyCount(1));
SyncTimingHelper::PrintResult("autofill", "delete_autofill_keys", dt);
} }
IN_PROC_BROWSER_TEST_F(AutofillSyncPerfTest, DISABLED_Benchmark) { IN_PROC_BROWSER_TEST_F(AutofillSyncPerfTest, DISABLED_Benchmark) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment