summaryrefslogtreecommitdiffstats
path: root/base/debug
diff options
context:
space:
mode:
authornduca@chromium.org <nduca@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-24 02:25:20 +0000
committernduca@chromium.org <nduca@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-24 02:25:20 +0000
commitf78044c9d030a32cc115fda249abcf421867b746 (patch)
treee0eb77a972a470f7663cbfb253694cb9ba468bab /base/debug
parent3397a04e2e97f9ea9ea5d9b5509ebcdc2d607592 (diff)
downloadchromium_src-f78044c9d030a32cc115fda249abcf421867b746.zip
chromium_src-f78044c9d030a32cc115fda249abcf421867b746.tar.gz
chromium_src-f78044c9d030a32cc115fda249abcf421867b746.tar.bz2
Add cpu count to trace metadata
TBR for analyzer changes, which are just fixes to the analyzer unit tests. R=dsinclair CC=epenner TBR=willchan Review URL: https://codereview.chromium.org/277883002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@272682 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/debug')
-rw-r--r--base/debug/trace_event_impl.cc8
-rw-r--r--base/debug/trace_event_unittest.cc30
2 files changed, 38 insertions, 0 deletions
diff --git a/base/debug/trace_event_impl.cc b/base/debug/trace_event_impl.cc
index a01a103..8bcbe0e 100644
--- a/base/debug/trace_event_impl.cc
+++ b/base/debug/trace_event_impl.cc
@@ -2049,6 +2049,14 @@ void TraceLog::CancelWatchEvent() {
void TraceLog::AddMetadataEventsWhileLocked() {
lock_.AssertAcquired();
+#if !defined(OS_NACL) // NaCl shouldn't expose the process id.
+ InitializeMetadataEvent(AddEventToThreadSharedChunkWhileLocked(NULL, false),
+ 0,
+ "num_cpus", "number",
+ base::SysInfo::NumberOfProcessors());
+#endif
+
+
int current_thread_id = static_cast<int>(base::PlatformThread::CurrentId());
if (process_sort_index_ != 0) {
InitializeMetadataEvent(AddEventToThreadSharedChunkWhileLocked(NULL, false),
diff --git a/base/debug/trace_event_unittest.cc b/base/debug/trace_event_unittest.cc
index 53e2330..c843c25 100644
--- a/base/debug/trace_event_unittest.cc
+++ b/base/debug/trace_event_unittest.cc
@@ -65,6 +65,7 @@ class TraceEventTestFixture : public testing::Test {
const char* phase,
const char* key,
const char* value);
+ void DropTracedMetadataRecords();
bool FindMatchingValue(const char* key,
const char* value);
bool FindNonMatchingValue(const char* key,
@@ -251,6 +252,28 @@ DictionaryValue* TraceEventTestFixture::FindMatchingTraceEntry(
return NULL;
}
+void TraceEventTestFixture::DropTracedMetadataRecords() {
+
+ scoped_ptr<ListValue> old_trace_parsed(trace_parsed_.DeepCopy());
+ size_t old_trace_parsed_size = old_trace_parsed->GetSize();
+ trace_parsed_.Clear();
+
+ for (size_t i = 0; i < old_trace_parsed_size; i++) {
+ Value* value = NULL;
+ old_trace_parsed->Get(i, &value);
+ if (!value || value->GetType() != Value::TYPE_DICTIONARY) {
+ trace_parsed_.Append(value->DeepCopy());
+ continue;
+ }
+ DictionaryValue* dict = static_cast<DictionaryValue*>(value);
+ std::string tmp;
+ if(dict->GetString("ph", &tmp) && tmp == "M")
+ continue;
+
+ trace_parsed_.Append(value->DeepCopy());
+ }
+}
+
DictionaryValue* TraceEventTestFixture::FindNamePhase(const char* name,
const char* phase) {
JsonKeyValue key_values[] = {
@@ -1102,6 +1125,7 @@ TEST_F(TraceEventTestFixture, Categories) {
TRACE_EVENT_INSTANT0("cat1", "name", TRACE_EVENT_SCOPE_THREAD);
TRACE_EVENT_INSTANT0("cat2", "name", TRACE_EVENT_SCOPE_THREAD);
EndTraceAndFlush();
+ DropTracedMetadataRecords();
EXPECT_TRUE(trace_parsed_.empty());
// Include existent category -> only events of that category
@@ -1113,6 +1137,7 @@ TEST_F(TraceEventTestFixture, Categories) {
TRACE_EVENT_INSTANT0("inc", "name", TRACE_EVENT_SCOPE_THREAD);
TRACE_EVENT_INSTANT0("inc2", "name", TRACE_EVENT_SCOPE_THREAD);
EndTraceAndFlush();
+ DropTracedMetadataRecords();
EXPECT_TRUE(FindMatchingValue("cat", "inc"));
EXPECT_FALSE(FindNonMatchingValue("cat", "inc"));
@@ -2288,6 +2313,7 @@ TEST_F(TraceEventCallbackTest, TraceEventCallbackAndRecording1) {
TRACE_EVENT_INSTANT0("recording", "no", TRACE_EVENT_SCOPE_GLOBAL);
TRACE_EVENT_INSTANT0("callback", "no", TRACE_EVENT_SCOPE_GLOBAL);
+ DropTracedMetadataRecords();
VerifyCallbackAndRecordedEvents(2, 2);
}
@@ -2311,6 +2337,7 @@ TEST_F(TraceEventCallbackTest, TraceEventCallbackAndRecording2) {
TRACE_EVENT_INSTANT0("recording", "no", TRACE_EVENT_SCOPE_GLOBAL);
TRACE_EVENT_INSTANT0("callback", "no", TRACE_EVENT_SCOPE_GLOBAL);
+ DropTracedMetadataRecords();
VerifyCallbackAndRecordedEvents(3, 1);
}
@@ -2334,6 +2361,7 @@ TEST_F(TraceEventCallbackTest, TraceEventCallbackAndRecording3) {
TRACE_EVENT_INSTANT0("recording", "no", TRACE_EVENT_SCOPE_GLOBAL);
TRACE_EVENT_INSTANT0("callback", "no", TRACE_EVENT_SCOPE_GLOBAL);
+ DropTracedMetadataRecords();
VerifyCallbackAndRecordedEvents(1, 3);
}
@@ -2357,6 +2385,7 @@ TEST_F(TraceEventCallbackTest, TraceEventCallbackAndRecording4) {
TRACE_EVENT_INSTANT0("recording", "no", TRACE_EVENT_SCOPE_GLOBAL);
TRACE_EVENT_INSTANT0("callback", "no", TRACE_EVENT_SCOPE_GLOBAL);
+ DropTracedMetadataRecords();
VerifyCallbackAndRecordedEvents(2, 2);
}
@@ -2787,6 +2816,7 @@ TEST_F(TraceEventTestFixture, TimeOffset) {
TimeTicks::NowFromSystemTraceTime().ToInternalValue());
EndTraceAndFlush();
+ DropTracedMetadataRecords();
double end_time = static_cast<double>(
(TimeTicks::NowFromSystemTraceTime() - time_offset).ToInternalValue());