| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/debug/trace_event_unittest.h" | |
| 7 #include "base/synchronization/waitable_event.h" | 6 #include "base/synchronization/waitable_event.h" |
| 8 #include "base/test/trace_event_analyzer.h" | 7 #include "base/test/trace_event_analyzer.h" |
| 8 #include "base/threading/platform_thread.h" |
| 9 #include "testing/gmock/include/gmock/gmock.h" | 9 #include "testing/gmock/include/gmock/gmock.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 | 11 |
| 12 namespace trace_analyzer { | 12 namespace trace_analyzer { |
| 13 | 13 |
| 14 namespace { | 14 namespace { |
| 15 | 15 |
| 16 class TraceEventAnalyzerTest : public testing::Test { | 16 class TraceEventAnalyzerTest : public testing::Test { |
| 17 public: | 17 public: |
| 18 void ManualSetUp(); | 18 void ManualSetUp(); |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 int64 duration_cutoff_us = (kSleepTime.InMicroseconds() * 9) / 10; | 402 int64 duration_cutoff_us = (kSleepTime.InMicroseconds() * 9) / 10; |
| 403 | 403 |
| 404 BeginTracing(); | 404 BeginTracing(); |
| 405 { | 405 { |
| 406 TRACE_EVENT_BEGIN0("cat1", "name1"); // found by duration query | 406 TRACE_EVENT_BEGIN0("cat1", "name1"); // found by duration query |
| 407 TRACE_EVENT_BEGIN0("noise", "name2"); // not searched for, just noise | 407 TRACE_EVENT_BEGIN0("noise", "name2"); // not searched for, just noise |
| 408 { | 408 { |
| 409 TRACE_EVENT_BEGIN0("cat2", "name3"); // found by duration query | 409 TRACE_EVENT_BEGIN0("cat2", "name3"); // found by duration query |
| 410 // next event not searched for, just noise | 410 // next event not searched for, just noise |
| 411 TRACE_EVENT_INSTANT0("noise", "name4", TRACE_EVENT_SCOPE_THREAD); | 411 TRACE_EVENT_INSTANT0("noise", "name4", TRACE_EVENT_SCOPE_THREAD); |
| 412 base::debug::HighResSleepForTraceTest(kSleepTime); | 412 base::PlatformThread::Sleep(kSleepTime); |
| 413 TRACE_EVENT_BEGIN0("cat2", "name5"); // not found (duration too short) | 413 TRACE_EVENT_BEGIN0("cat2", "name5"); // not found (duration too short) |
| 414 TRACE_EVENT_END0("cat2", "name5"); // not found (duration too short) | 414 TRACE_EVENT_END0("cat2", "name5"); // not found (duration too short) |
| 415 TRACE_EVENT_END0("cat2", "name3"); // found by duration query | 415 TRACE_EVENT_END0("cat2", "name3"); // found by duration query |
| 416 } | 416 } |
| 417 TRACE_EVENT_END0("noise", "name2"); // not searched for, just noise | 417 TRACE_EVENT_END0("noise", "name2"); // not searched for, just noise |
| 418 TRACE_EVENT_END0("cat1", "name1"); // found by duration query | 418 TRACE_EVENT_END0("cat1", "name1"); // found by duration query |
| 419 } | 419 } |
| 420 EndTracing(); | 420 EndTracing(); |
| 421 | 421 |
| 422 scoped_ptr<TraceAnalyzer> | 422 scoped_ptr<TraceAnalyzer> |
| (...skipping 25 matching lines...) Expand all Loading... |
| 448 int64 duration_cutoff_us = (kSleepTime.InMicroseconds() * 9) / 10; | 448 int64 duration_cutoff_us = (kSleepTime.InMicroseconds() * 9) / 10; |
| 449 | 449 |
| 450 BeginTracing(); | 450 BeginTracing(); |
| 451 { | 451 { |
| 452 TRACE_EVENT0("cat1", "name1"); // found by duration query | 452 TRACE_EVENT0("cat1", "name1"); // found by duration query |
| 453 TRACE_EVENT0("noise", "name2"); // not searched for, just noise | 453 TRACE_EVENT0("noise", "name2"); // not searched for, just noise |
| 454 { | 454 { |
| 455 TRACE_EVENT0("cat2", "name3"); // found by duration query | 455 TRACE_EVENT0("cat2", "name3"); // found by duration query |
| 456 // next event not searched for, just noise | 456 // next event not searched for, just noise |
| 457 TRACE_EVENT_INSTANT0("noise", "name4", TRACE_EVENT_SCOPE_THREAD); | 457 TRACE_EVENT_INSTANT0("noise", "name4", TRACE_EVENT_SCOPE_THREAD); |
| 458 base::debug::HighResSleepForTraceTest(kSleepTime); | 458 base::PlatformThread::Sleep(kSleepTime); |
| 459 TRACE_EVENT0("cat2", "name5"); // not found (duration too short) | 459 TRACE_EVENT0("cat2", "name5"); // not found (duration too short) |
| 460 } | 460 } |
| 461 } | 461 } |
| 462 EndTracing(); | 462 EndTracing(); |
| 463 | 463 |
| 464 scoped_ptr<TraceAnalyzer> | 464 scoped_ptr<TraceAnalyzer> |
| 465 analyzer(TraceAnalyzer::Create(output_.json_output)); | 465 analyzer(TraceAnalyzer::Create(output_.json_output)); |
| 466 ASSERT_TRUE(analyzer.get()); | 466 ASSERT_TRUE(analyzer.get()); |
| 467 analyzer->AssociateBeginEndEvents(); | 467 analyzer->AssociateBeginEndEvents(); |
| 468 | 468 |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 886 EXPECT_EQ(num_events, CountMatches(event_ptrs, Query::Bool(true))); | 886 EXPECT_EQ(num_events, CountMatches(event_ptrs, Query::Bool(true))); |
| 887 EXPECT_EQ(num_events - 1, CountMatches(event_ptrs, Query::Bool(true), | 887 EXPECT_EQ(num_events - 1, CountMatches(event_ptrs, Query::Bool(true), |
| 888 1, num_events)); | 888 1, num_events)); |
| 889 EXPECT_EQ(1u, CountMatches(event_ptrs, query_one)); | 889 EXPECT_EQ(1u, CountMatches(event_ptrs, query_one)); |
| 890 EXPECT_EQ(num_events - 1, CountMatches(event_ptrs, !query_one)); | 890 EXPECT_EQ(num_events - 1, CountMatches(event_ptrs, !query_one)); |
| 891 EXPECT_EQ(num_named, CountMatches(event_ptrs, query_named)); | 891 EXPECT_EQ(num_named, CountMatches(event_ptrs, query_named)); |
| 892 } | 892 } |
| 893 | 893 |
| 894 | 894 |
| 895 } // namespace trace_analyzer | 895 } // namespace trace_analyzer |
| OLD | NEW |