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

Side by Side Diff: base/trace_event/trace_event_unittest.cc

Issue 1424703003: Kills TraceTicks, which was functionally the same as TimeTicks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed win compile error. Created 5 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « base/trace_event/trace_event_impl.cc ('k') | base/trace_event/trace_log.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <math.h> 5 #include <math.h>
6 #include <cstdlib> 6 #include <cstdlib>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
(...skipping 2344 matching lines...) Expand 10 before | Expand all | Expand 10 after
2355 const std::string& category, 2355 const std::string& category,
2356 const std::string& name) { 2356 const std::string& name) {
2357 EXPECT_EQ(phase, collected_events_phases_[i]); 2357 EXPECT_EQ(phase, collected_events_phases_[i]);
2358 EXPECT_EQ(category, collected_events_categories_[i]); 2358 EXPECT_EQ(category, collected_events_categories_[i]);
2359 EXPECT_EQ(name, collected_events_names_[i]); 2359 EXPECT_EQ(name, collected_events_names_[i]);
2360 } 2360 }
2361 2361
2362 std::vector<std::string> collected_events_categories_; 2362 std::vector<std::string> collected_events_categories_;
2363 std::vector<std::string> collected_events_names_; 2363 std::vector<std::string> collected_events_names_;
2364 std::vector<unsigned char> collected_events_phases_; 2364 std::vector<unsigned char> collected_events_phases_;
2365 std::vector<TraceTicks> collected_events_timestamps_; 2365 std::vector<TimeTicks> collected_events_timestamps_;
2366 2366
2367 static TraceEventCallbackTest* s_instance; 2367 static TraceEventCallbackTest* s_instance;
2368 static void Callback(TraceTicks timestamp, 2368 static void Callback(TimeTicks timestamp,
2369 char phase, 2369 char phase,
2370 const unsigned char* category_group_enabled, 2370 const unsigned char* category_group_enabled,
2371 const char* name, 2371 const char* name,
2372 unsigned long long id, 2372 unsigned long long id,
2373 int num_args, 2373 int num_args,
2374 const char* const arg_names[], 2374 const char* const arg_names[],
2375 const unsigned char arg_types[], 2375 const unsigned char arg_types[],
2376 const unsigned long long arg_values[], 2376 const unsigned long long arg_values[],
2377 unsigned int flags) { 2377 unsigned int flags) {
2378 s_instance->collected_events_phases_.push_back(phase); 2378 s_instance->collected_events_phases_.push_back(phase);
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
2544 } 2544 }
2545 2545
2546 TEST_F(TraceEventTestFixture, TraceBufferVectorReportFull) { 2546 TEST_F(TraceEventTestFixture, TraceBufferVectorReportFull) {
2547 TraceLog* trace_log = TraceLog::GetInstance(); 2547 TraceLog* trace_log = TraceLog::GetInstance();
2548 trace_log->SetEnabled( 2548 trace_log->SetEnabled(
2549 TraceConfig(kRecordAllCategoryFilter, ""), TraceLog::RECORDING_MODE); 2549 TraceConfig(kRecordAllCategoryFilter, ""), TraceLog::RECORDING_MODE);
2550 trace_log->logged_events_.reset( 2550 trace_log->logged_events_.reset(
2551 TraceBuffer::CreateTraceBufferVectorOfSize(100)); 2551 TraceBuffer::CreateTraceBufferVectorOfSize(100));
2552 do { 2552 do {
2553 TRACE_EVENT_BEGIN_WITH_ID_TID_AND_TIMESTAMP0( 2553 TRACE_EVENT_BEGIN_WITH_ID_TID_AND_TIMESTAMP0(
2554 "all", "with_timestamp", 0, 0, TraceTicks::Now().ToInternalValue()); 2554 "all", "with_timestamp", 0, 0, TimeTicks::Now().ToInternalValue());
2555 TRACE_EVENT_END_WITH_ID_TID_AND_TIMESTAMP0( 2555 TRACE_EVENT_END_WITH_ID_TID_AND_TIMESTAMP0(
2556 "all", "with_timestamp", 0, 0, TraceTicks::Now().ToInternalValue()); 2556 "all", "with_timestamp", 0, 0, TimeTicks::Now().ToInternalValue());
2557 } while (!trace_log->BufferIsFull()); 2557 } while (!trace_log->BufferIsFull());
2558 2558
2559 EndTraceAndFlush(); 2559 EndTraceAndFlush();
2560 2560
2561 const DictionaryValue* trace_full_metadata = NULL; 2561 const DictionaryValue* trace_full_metadata = NULL;
2562 2562
2563 trace_full_metadata = FindTraceEntry(trace_parsed_, 2563 trace_full_metadata = FindTraceEntry(trace_parsed_,
2564 "overflowed_at_ts"); 2564 "overflowed_at_ts");
2565 std::string phase; 2565 std::string phase;
2566 double buffer_limit_reached_timestamp = 0; 2566 double buffer_limit_reached_timestamp = 0;
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
2919 TRACE_EVENT0("b", "duration"); 2919 TRACE_EVENT0("b", "duration");
2920 } 2920 }
2921 2921
2922 EndTraceAndFlush(); 2922 EndTraceAndFlush();
2923 logging::SetLogMessageHandler(old_log_message_handler); 2923 logging::SetLogMessageHandler(old_log_message_handler);
2924 } 2924 }
2925 2925
2926 TEST_F(TraceEventTestFixture, TimeOffset) { 2926 TEST_F(TraceEventTestFixture, TimeOffset) {
2927 BeginTrace(); 2927 BeginTrace();
2928 // Let TraceLog timer start from 0. 2928 // Let TraceLog timer start from 0.
2929 TimeDelta time_offset = TraceTicks::Now() - TraceTicks(); 2929 TimeDelta time_offset = TimeTicks::Now() - TimeTicks();
2930 TraceLog::GetInstance()->SetTimeOffset(time_offset); 2930 TraceLog::GetInstance()->SetTimeOffset(time_offset);
2931 2931
2932 { 2932 {
2933 TRACE_EVENT0("all", "duration1"); 2933 TRACE_EVENT0("all", "duration1");
2934 TRACE_EVENT0("all", "duration2"); 2934 TRACE_EVENT0("all", "duration2");
2935 } 2935 }
2936 TRACE_EVENT_BEGIN_WITH_ID_TID_AND_TIMESTAMP0( 2936 TRACE_EVENT_BEGIN_WITH_ID_TID_AND_TIMESTAMP0(
2937 "all", "with_timestamp", 0, 0, TraceTicks::Now().ToInternalValue()); 2937 "all", "with_timestamp", 0, 0, TimeTicks::Now().ToInternalValue());
2938 TRACE_EVENT_END_WITH_ID_TID_AND_TIMESTAMP0( 2938 TRACE_EVENT_END_WITH_ID_TID_AND_TIMESTAMP0(
2939 "all", "with_timestamp", 0, 0, TraceTicks::Now().ToInternalValue()); 2939 "all", "with_timestamp", 0, 0, TimeTicks::Now().ToInternalValue());
2940 2940
2941 EndTraceAndFlush(); 2941 EndTraceAndFlush();
2942 DropTracedMetadataRecords(); 2942 DropTracedMetadataRecords();
2943 2943
2944 double end_time = static_cast<double>( 2944 double end_time = static_cast<double>(
2945 (TraceTicks::Now() - time_offset).ToInternalValue()); 2945 (TimeTicks::Now() - time_offset).ToInternalValue());
2946 double last_timestamp = 0; 2946 double last_timestamp = 0;
2947 for (size_t i = 0; i < trace_parsed_.GetSize(); ++i) { 2947 for (size_t i = 0; i < trace_parsed_.GetSize(); ++i) {
2948 const DictionaryValue* item; 2948 const DictionaryValue* item;
2949 EXPECT_TRUE(trace_parsed_.GetDictionary(i, &item)); 2949 EXPECT_TRUE(trace_parsed_.GetDictionary(i, &item));
2950 double timestamp; 2950 double timestamp;
2951 EXPECT_TRUE(item->GetDouble("ts", &timestamp)); 2951 EXPECT_TRUE(item->GetDouble("ts", &timestamp));
2952 EXPECT_GE(timestamp, last_timestamp); 2952 EXPECT_GE(timestamp, last_timestamp);
2953 EXPECT_LE(timestamp, end_time); 2953 EXPECT_LE(timestamp, end_time);
2954 last_timestamp = timestamp; 2954 last_timestamp = timestamp;
2955 } 2955 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
2993 } 2993 }
2994 2994
2995 TEST_F(TraceEventTestFixture, SyntheticDelayConfigurationToString) { 2995 TEST_F(TraceEventTestFixture, SyntheticDelayConfigurationToString) {
2996 const char filter[] = "DELAY(test.Delay;16;oneshot)"; 2996 const char filter[] = "DELAY(test.Delay;16;oneshot)";
2997 TraceConfig config(filter, ""); 2997 TraceConfig config(filter, "");
2998 EXPECT_EQ(filter, config.ToCategoryFilterString()); 2998 EXPECT_EQ(filter, config.ToCategoryFilterString());
2999 } 2999 }
3000 3000
3001 } // namespace trace_event 3001 } // namespace trace_event
3002 } // namespace base 3002 } // namespace base
OLDNEW
« no previous file with comments | « base/trace_event/trace_event_impl.cc ('k') | base/trace_event/trace_log.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698