summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorskyostil@chromium.org <skyostil@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-14 17:41:49 +0000
committerskyostil@chromium.org <skyostil@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-14 17:41:49 +0000
commitc54d851c9313198e23082cafee66db4b3813f128 (patch)
treeb50b97706bdb9995213f7ba36eb46852af4ccadf /base
parente65ace0447e582849325b9c846ca65104c269971 (diff)
downloadchromium_src-c54d851c9313198e23082cafee66db4b3813f128.zip
chromium_src-c54d851c9313198e23082cafee66db4b3813f128.tar.gz
chromium_src-c54d851c9313198e23082cafee66db4b3813f128.tar.bz2
Reduce binary size impact of synthetic delays
This patch reduces the binary size impact of synthetic delays. Namely: 1. Use strtod() instead of base::StringToDouble. Saves 12K on x64 for targets that did not already use base::StringToDouble (e.g., nacl_helper). 2. Use std::vector<std::string> instead of std::vector<std::pair<std::string, std::string>>. Saves 5K. The remaining binary size impact for the feature is about 6K. BUG=307841,333373 TEST=TraceEventTestFixture.*Delay* Review URL: https://codereview.chromium.org/136723006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@244761 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/debug/trace_event_impl.cc28
-rw-r--r--base/debug/trace_event_impl.h11
2 files changed, 19 insertions, 20 deletions
diff --git a/base/debug/trace_event_impl.cc b/base/debug/trace_event_impl.cc
index b3e0cb8..a7dc8d9 100644
--- a/base/debug/trace_event_impl.cc
+++ b/base/debug/trace_event_impl.cc
@@ -1214,16 +1214,19 @@ void TraceLog::UpdateCategoryGroupEnabledFlags() {
void TraceLog::UpdateSyntheticDelaysFromCategoryFilter() {
ResetTraceEventSyntheticDelays();
- const CategoryFilter::DelayValueList& delays =
+ const CategoryFilter::StringList& delays =
category_filter_.GetSyntheticDelayValues();
- CategoryFilter::DelayValueList::const_iterator ci;
+ CategoryFilter::StringList::const_iterator ci;
for (ci = delays.begin(); ci != delays.end(); ++ci) {
+ StringTokenizer tokens(*ci, ";");
+ if (!tokens.GetNext())
+ continue;
TraceEventSyntheticDelay* delay =
- TraceEventSyntheticDelay::Lookup(ci->first);
- StringTokenizer tokens(ci->second, ";");
+ TraceEventSyntheticDelay::Lookup(tokens.token());
while (tokens.GetNext()) {
- double target_duration;
- if (StringToDouble(tokens.token(), &target_duration)) {
+ char* duration_end;
+ double target_duration = strtod(tokens.token().c_str(), &duration_end);
+ if (duration_end != tokens.token().c_str()) {
delay->SetTargetDuration(
TimeDelta::FromMicroseconds(target_duration * 1e6));
} else if (tokens.token() == "static") {
@@ -2241,8 +2244,7 @@ void CategoryFilter::Initialize(const std::string& filter_string) {
size_t name_length = category.find(';');
if (name_length != std::string::npos && name_length > 0 &&
name_length != category.size() - 1) {
- delays_.push_back(DelayValue(category.substr(0, name_length),
- category.substr(name_length + 1)));
+ delays_.push_back(category);
}
} else if (category.at(0) == '-') {
// Excluded categories start with '-'.
@@ -2272,16 +2274,16 @@ void CategoryFilter::WriteString(const StringList& values,
}
}
-void CategoryFilter::WriteString(const DelayValueList& delays,
+void CategoryFilter::WriteString(const StringList& delays,
std::string* out) const {
bool prepend_comma = !out->empty();
int token_cnt = 0;
- for (DelayValueList::const_iterator ci = delays.begin();
+ for (StringList::const_iterator ci = delays.begin();
ci != delays.end(); ++ci) {
if (token_cnt > 0 || prepend_comma)
StringAppendF(out, ",");
- StringAppendF(out, "%s%s;%s)", kSyntheticDelayCategoryFilterPrefix,
- ci->first.c_str(), ci->second.c_str());
+ StringAppendF(out, "%s%s)", kSyntheticDelayCategoryFilterPrefix,
+ ci->c_str());
++token_cnt;
}
}
@@ -2358,7 +2360,7 @@ void CategoryFilter::Clear() {
excluded_.clear();
}
-const CategoryFilter::DelayValueList&
+const CategoryFilter::StringList&
CategoryFilter::GetSyntheticDelayValues() const {
return delays_;
}
diff --git a/base/debug/trace_event_impl.h b/base/debug/trace_event_impl.h
index e84ccbe..f4efb7d 100644
--- a/base/debug/trace_event_impl.h
+++ b/base/debug/trace_event_impl.h
@@ -283,8 +283,7 @@ class BASE_EXPORT TraceResultBuffer {
class BASE_EXPORT CategoryFilter {
public:
- typedef std::pair<std::string, std::string> DelayValue;
- typedef std::vector<DelayValue> DelayValueList;
+ typedef std::vector<std::string> StringList;
// The default category filter, used when none is provided.
// Allows all categories through, except if they end in the suffix 'Debug' or
@@ -331,7 +330,7 @@ class BASE_EXPORT CategoryFilter {
bool IsCategoryGroupEnabled(const char* category_group) const;
// Return a list of the synthetic delays specified in this category filter.
- const DelayValueList& GetSyntheticDelayValues() const;
+ const StringList& GetSyntheticDelayValues() const;
// Merges nested_filter with the current CategoryFilter
void Merge(const CategoryFilter& nested_filter);
@@ -350,13 +349,11 @@ class BASE_EXPORT CategoryFilter {
static bool IsEmptyOrContainsLeadingOrTrailingWhitespace(
const std::string& str);
- typedef std::vector<std::string> StringList;
-
void Initialize(const std::string& filter_string);
void WriteString(const StringList& values,
std::string* out,
bool included) const;
- void WriteString(const DelayValueList& delays, std::string* out) const;
+ void WriteString(const StringList& delays, std::string* out) const;
bool HasIncludedPatterns() const;
bool DoesCategoryGroupContainCategory(const char* category_group,
@@ -365,7 +362,7 @@ class BASE_EXPORT CategoryFilter {
StringList included_;
StringList disabled_;
StringList excluded_;
- DelayValueList delays_;
+ StringList delays_;
};
class TraceSamplingThread;