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 <stddef.h> |
| 6 #include <stdint.h> |
| 7 |
5 #include "base/bind.h" | 8 #include "base/bind.h" |
6 #include "base/synchronization/waitable_event.h" | 9 #include "base/synchronization/waitable_event.h" |
7 #include "base/test/trace_event_analyzer.h" | 10 #include "base/test/trace_event_analyzer.h" |
8 #include "base/threading/platform_thread.h" | 11 #include "base/threading/platform_thread.h" |
9 #include "base/trace_event/trace_buffer.h" | 12 #include "base/trace_event/trace_buffer.h" |
10 #include "testing/gmock/include/gmock/gmock.h" | 13 #include "testing/gmock/include/gmock/gmock.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
12 | 15 |
13 namespace trace_analyzer { | 16 namespace trace_analyzer { |
14 | 17 |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 EXPECT_STREQ("no match", found[0]->name.c_str()); | 395 EXPECT_STREQ("no match", found[0]->name.c_str()); |
393 } | 396 } |
394 | 397 |
395 // Test that duration queries work. | 398 // Test that duration queries work. |
396 TEST_F(TraceEventAnalyzerTest, BeginEndDuration) { | 399 TEST_F(TraceEventAnalyzerTest, BeginEndDuration) { |
397 ManualSetUp(); | 400 ManualSetUp(); |
398 | 401 |
399 const base::TimeDelta kSleepTime = base::TimeDelta::FromMilliseconds(200); | 402 const base::TimeDelta kSleepTime = base::TimeDelta::FromMilliseconds(200); |
400 // We will search for events that have a duration of greater than 90% of the | 403 // We will search for events that have a duration of greater than 90% of the |
401 // sleep time, so that there is no flakiness. | 404 // sleep time, so that there is no flakiness. |
402 int64 duration_cutoff_us = (kSleepTime.InMicroseconds() * 9) / 10; | 405 int64_t duration_cutoff_us = (kSleepTime.InMicroseconds() * 9) / 10; |
403 | 406 |
404 BeginTracing(); | 407 BeginTracing(); |
405 { | 408 { |
406 TRACE_EVENT_BEGIN0("cat1", "name1"); // found by duration query | 409 TRACE_EVENT_BEGIN0("cat1", "name1"); // found by duration query |
407 TRACE_EVENT_BEGIN0("noise", "name2"); // not searched for, just noise | 410 TRACE_EVENT_BEGIN0("noise", "name2"); // not searched for, just noise |
408 { | 411 { |
409 TRACE_EVENT_BEGIN0("cat2", "name3"); // found by duration query | 412 TRACE_EVENT_BEGIN0("cat2", "name3"); // found by duration query |
410 // next event not searched for, just noise | 413 // next event not searched for, just noise |
411 TRACE_EVENT_INSTANT0("noise", "name4", TRACE_EVENT_SCOPE_THREAD); | 414 TRACE_EVENT_INSTANT0("noise", "name4", TRACE_EVENT_SCOPE_THREAD); |
412 base::PlatformThread::Sleep(kSleepTime); | 415 base::PlatformThread::Sleep(kSleepTime); |
(...skipping 25 matching lines...) Expand all Loading... |
438 EXPECT_STREQ("name3", found[1]->name.c_str()); | 441 EXPECT_STREQ("name3", found[1]->name.c_str()); |
439 } | 442 } |
440 | 443 |
441 // Test that duration queries work. | 444 // Test that duration queries work. |
442 TEST_F(TraceEventAnalyzerTest, CompleteDuration) { | 445 TEST_F(TraceEventAnalyzerTest, CompleteDuration) { |
443 ManualSetUp(); | 446 ManualSetUp(); |
444 | 447 |
445 const base::TimeDelta kSleepTime = base::TimeDelta::FromMilliseconds(200); | 448 const base::TimeDelta kSleepTime = base::TimeDelta::FromMilliseconds(200); |
446 // We will search for events that have a duration of greater than 90% of the | 449 // We will search for events that have a duration of greater than 90% of the |
447 // sleep time, so that there is no flakiness. | 450 // sleep time, so that there is no flakiness. |
448 int64 duration_cutoff_us = (kSleepTime.InMicroseconds() * 9) / 10; | 451 int64_t duration_cutoff_us = (kSleepTime.InMicroseconds() * 9) / 10; |
449 | 452 |
450 BeginTracing(); | 453 BeginTracing(); |
451 { | 454 { |
452 TRACE_EVENT0("cat1", "name1"); // found by duration query | 455 TRACE_EVENT0("cat1", "name1"); // found by duration query |
453 TRACE_EVENT0("noise", "name2"); // not searched for, just noise | 456 TRACE_EVENT0("noise", "name2"); // not searched for, just noise |
454 { | 457 { |
455 TRACE_EVENT0("cat2", "name3"); // found by duration query | 458 TRACE_EVENT0("cat2", "name3"); // found by duration query |
456 // next event not searched for, just noise | 459 // next event not searched for, just noise |
457 TRACE_EVENT_INSTANT0("noise", "name4", TRACE_EVENT_SCOPE_THREAD); | 460 TRACE_EVENT_INSTANT0("noise", "name4", TRACE_EVENT_SCOPE_THREAD); |
458 base::PlatformThread::Sleep(kSleepTime); | 461 base::PlatformThread::Sleep(kSleepTime); |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
886 EXPECT_EQ(num_events, CountMatches(event_ptrs, Query::Bool(true))); | 889 EXPECT_EQ(num_events, CountMatches(event_ptrs, Query::Bool(true))); |
887 EXPECT_EQ(num_events - 1, CountMatches(event_ptrs, Query::Bool(true), | 890 EXPECT_EQ(num_events - 1, CountMatches(event_ptrs, Query::Bool(true), |
888 1, num_events)); | 891 1, num_events)); |
889 EXPECT_EQ(1u, CountMatches(event_ptrs, query_one)); | 892 EXPECT_EQ(1u, CountMatches(event_ptrs, query_one)); |
890 EXPECT_EQ(num_events - 1, CountMatches(event_ptrs, !query_one)); | 893 EXPECT_EQ(num_events - 1, CountMatches(event_ptrs, !query_one)); |
891 EXPECT_EQ(num_named, CountMatches(event_ptrs, query_named)); | 894 EXPECT_EQ(num_named, CountMatches(event_ptrs, query_named)); |
892 } | 895 } |
893 | 896 |
894 | 897 |
895 } // namespace trace_analyzer | 898 } // namespace trace_analyzer |
OLD | NEW |