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

Unified Diff: components/metrics/call_stack_profile_metrics_provider_unittest.cc

Issue 2438073002: Use movable types for CallStackProfile(s) to remove copying of data. (Closed)
Patch Set: fix tests and build problems Created 4 years, 2 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: components/metrics/call_stack_profile_metrics_provider_unittest.cc
diff --git a/components/metrics/call_stack_profile_metrics_provider_unittest.cc b/components/metrics/call_stack_profile_metrics_provider_unittest.cc
index e5dfb9ad9f6017c2dda8b0930815db6afe92c9f7..a7e4ef6a4cf05c1a52c0ebddd50e0b627bea6880 100644
--- a/components/metrics/call_stack_profile_metrics_provider_unittest.cc
+++ b/components/metrics/call_stack_profile_metrics_provider_unittest.cc
@@ -42,9 +42,9 @@ class CallStackProfileMetricsProviderTest : public testing::Test {
~CallStackProfileMetricsProviderTest() override {}
// Utility function to append profiles to the metrics provider.
- void AppendProfiles(const CallStackProfileParams& params,
- const Profiles& profiles) {
- CallStackProfileMetricsProvider::GetProfilerCallback(params).Run(profiles);
+ void AppendProfiles(const CallStackProfileParams& params, Profiles profiles) {
+ CallStackProfileMetricsProvider::GetProfilerCallback(params).Run(
+ std::move(profiles));
}
private:
@@ -199,7 +199,7 @@ TEST_F(CallStackProfileMetricsProviderTest, MultipleProfiles) {
profile.profile_duration = profile_durations[i];
profile.sampling_period = profile_sampling_periods[i];
- profiles.push_back(profile);
+ profiles.push_back(std::move(profile));
}
CallStackProfileMetricsProvider provider;
@@ -209,7 +209,7 @@ TEST_F(CallStackProfileMetricsProviderTest, MultipleProfiles) {
CallStackProfileParams::UI_THREAD,
CallStackProfileParams::PROCESS_STARTUP,
CallStackProfileParams::MAY_SHUFFLE),
- profiles);
+ std::move(profiles));
ChromeUserMetricsExtension uma_proto;
provider.ProvideGeneralMetrics(&uma_proto);
@@ -316,6 +316,8 @@ TEST_F(CallStackProfileMetricsProviderTest, RepeatedStacksUnordered) {
profile.profile_duration = base::TimeDelta::FromMilliseconds(100);
profile.sampling_period = base::TimeDelta::FromMilliseconds(10);
+ Profiles profiles;
+ profiles.push_back(std::move(profile));
CallStackProfileMetricsProvider provider;
provider.OnRecordingEnabled();
@@ -324,7 +326,7 @@ TEST_F(CallStackProfileMetricsProviderTest, RepeatedStacksUnordered) {
CallStackProfileParams::UI_THREAD,
CallStackProfileParams::PROCESS_STARTUP,
CallStackProfileParams::MAY_SHUFFLE),
- std::vector<Profile>(1, profile));
+ std::move(profiles));
ChromeUserMetricsExtension uma_proto;
provider.ProvideGeneralMetrics(&uma_proto);
@@ -399,6 +401,8 @@ TEST_F(CallStackProfileMetricsProviderTest, RepeatedStacksOrdered) {
profile.profile_duration = base::TimeDelta::FromMilliseconds(100);
profile.sampling_period = base::TimeDelta::FromMilliseconds(10);
+ Profiles profiles;
+ profiles.push_back(std::move(profile));
CallStackProfileMetricsProvider provider;
provider.OnRecordingEnabled();
@@ -406,7 +410,7 @@ TEST_F(CallStackProfileMetricsProviderTest, RepeatedStacksOrdered) {
CallStackProfileParams::UI_THREAD,
CallStackProfileParams::PROCESS_STARTUP,
CallStackProfileParams::PRESERVE_ORDER),
- std::vector<Profile>(1, profile));
+ std::move(profiles));
ChromeUserMetricsExtension uma_proto;
provider.ProvideGeneralMetrics(&uma_proto);
@@ -453,6 +457,8 @@ TEST_F(CallStackProfileMetricsProviderTest, UnknownModule) {
profile.profile_duration = base::TimeDelta::FromMilliseconds(100);
profile.sampling_period = base::TimeDelta::FromMilliseconds(10);
+ Profiles profiles;
+ profiles.push_back(std::move(profile));
CallStackProfileMetricsProvider provider;
provider.OnRecordingEnabled();
@@ -461,7 +467,7 @@ TEST_F(CallStackProfileMetricsProviderTest, UnknownModule) {
CallStackProfileParams::UI_THREAD,
CallStackProfileParams::PROCESS_STARTUP,
CallStackProfileParams::MAY_SHUFFLE),
- std::vector<Profile>(1, profile));
+ std::move(profiles));
ChromeUserMetricsExtension uma_proto;
provider.ProvideGeneralMetrics(&uma_proto);
@@ -494,6 +500,8 @@ TEST_F(CallStackProfileMetricsProviderTest, ProfilesProvidedOnlyOnce) {
profile.profile_duration = base::TimeDelta::FromMilliseconds(100);
// Use the sampling period to distinguish the two profiles.
profile.sampling_period = base::TimeDelta::FromMilliseconds(i);
+ Profiles profiles;
+ profiles.push_back(std::move(profile));
provider.OnRecordingEnabled();
AppendProfiles(
@@ -501,7 +509,7 @@ TEST_F(CallStackProfileMetricsProviderTest, ProfilesProvidedOnlyOnce) {
CallStackProfileParams::UI_THREAD,
CallStackProfileParams::PROCESS_STARTUP,
CallStackProfileParams::MAY_SHUFFLE),
- std::vector<Profile>(1, profile));
+ std::move(profiles));
ChromeUserMetricsExtension uma_proto;
provider.ProvideGeneralMetrics(&uma_proto);
@@ -525,13 +533,15 @@ TEST_F(CallStackProfileMetricsProviderTest,
profile.profile_duration = base::TimeDelta::FromMilliseconds(100);
profile.sampling_period = base::TimeDelta::FromMilliseconds(10);
+ Profiles profiles;
+ profiles.push_back(std::move(profile));
AppendProfiles(
CallStackProfileParams(CallStackProfileParams::BROWSER_PROCESS,
CallStackProfileParams::UI_THREAD,
CallStackProfileParams::PROCESS_STARTUP,
CallStackProfileParams::MAY_SHUFFLE),
- std::vector<Profile>(1, profile));
+ std::move(profiles));
CallStackProfileMetricsProvider provider;
provider.OnRecordingEnabled();
@@ -550,6 +560,8 @@ TEST_F(CallStackProfileMetricsProviderTest, ProfilesNotProvidedWhileDisabled) {
profile.profile_duration = base::TimeDelta::FromMilliseconds(100);
profile.sampling_period = base::TimeDelta::FromMilliseconds(10);
+ Profiles profiles;
+ profiles.push_back(std::move(profile));
CallStackProfileMetricsProvider provider;
provider.OnRecordingDisabled();
@@ -558,7 +570,7 @@ TEST_F(CallStackProfileMetricsProviderTest, ProfilesNotProvidedWhileDisabled) {
CallStackProfileParams::UI_THREAD,
CallStackProfileParams::PROCESS_STARTUP,
CallStackProfileParams::MAY_SHUFFLE),
- std::vector<Profile>(1, profile));
+ std::move(profiles));
ChromeUserMetricsExtension uma_proto;
provider.ProvideGeneralMetrics(&uma_proto);
@@ -586,7 +598,9 @@ TEST_F(CallStackProfileMetricsProviderTest,
CallStackProfileParams::MAY_SHUFFLE));
provider.OnRecordingDisabled();
- callback.Run(std::vector<Profile>(1, profile));
+ Profiles profiles;
+ profiles.push_back(std::move(profile));
+ callback.Run(std::move(profiles));
ChromeUserMetricsExtension uma_proto;
provider.ProvideGeneralMetrics(&uma_proto);
@@ -615,7 +629,9 @@ TEST_F(CallStackProfileMetricsProviderTest,
provider.OnRecordingDisabled();
provider.OnRecordingEnabled();
- callback.Run(std::vector<Profile>(1, profile));
+ Profiles profiles;
+ profiles.push_back(std::move(profile));
+ callback.Run(std::move(profiles));
ChromeUserMetricsExtension uma_proto;
provider.ProvideGeneralMetrics(&uma_proto);
@@ -643,7 +659,9 @@ TEST_F(CallStackProfileMetricsProviderTest,
CallStackProfileParams::MAY_SHUFFLE));
provider.OnRecordingEnabled();
- callback.Run(std::vector<Profile>(1, profile));
+ Profiles profiles;
+ profiles.push_back(std::move(profile));
+ callback.Run(std::move(profiles));
ChromeUserMetricsExtension uma_proto;
provider.ProvideGeneralMetrics(&uma_proto);

Powered by Google App Engine
This is Rietveld 408576698