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

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

Issue 1121463005: Fixit: Split base::TimeTicks --> TimeTicks + ThreadTicks + TraceTicks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More Windows compile fixes. Created 5 years, 7 months 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') | cc/debug/lap_timer.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 2232 matching lines...) Expand 10 before | Expand all | Expand 10 after
2243 const std::string& category, 2243 const std::string& category,
2244 const std::string& name) { 2244 const std::string& name) {
2245 EXPECT_EQ(phase, collected_events_phases_[i]); 2245 EXPECT_EQ(phase, collected_events_phases_[i]);
2246 EXPECT_EQ(category, collected_events_categories_[i]); 2246 EXPECT_EQ(category, collected_events_categories_[i]);
2247 EXPECT_EQ(name, collected_events_names_[i]); 2247 EXPECT_EQ(name, collected_events_names_[i]);
2248 } 2248 }
2249 2249
2250 std::vector<std::string> collected_events_categories_; 2250 std::vector<std::string> collected_events_categories_;
2251 std::vector<std::string> collected_events_names_; 2251 std::vector<std::string> collected_events_names_;
2252 std::vector<unsigned char> collected_events_phases_; 2252 std::vector<unsigned char> collected_events_phases_;
2253 std::vector<TimeTicks> collected_events_timestamps_; 2253 std::vector<TraceTicks> collected_events_timestamps_;
2254 2254
2255 static TraceEventCallbackTest* s_instance; 2255 static TraceEventCallbackTest* s_instance;
2256 static void Callback(TimeTicks timestamp, 2256 static void Callback(TraceTicks timestamp,
2257 char phase, 2257 char phase,
2258 const unsigned char* category_group_enabled, 2258 const unsigned char* category_group_enabled,
2259 const char* name, 2259 const char* name,
2260 unsigned long long id, 2260 unsigned long long id,
2261 int num_args, 2261 int num_args,
2262 const char* const arg_names[], 2262 const char* const arg_names[],
2263 const unsigned char arg_types[], 2263 const unsigned char arg_types[],
2264 const unsigned long long arg_values[], 2264 const unsigned long long arg_values[],
2265 unsigned char flags) { 2265 unsigned char flags) {
2266 s_instance->collected_events_phases_.push_back(phase); 2266 s_instance->collected_events_phases_.push_back(phase);
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
2445 2445
2446 TEST_F(TraceEventTestFixture, TraceBufferVectorReportFull) { 2446 TEST_F(TraceEventTestFixture, TraceBufferVectorReportFull) {
2447 TraceLog* trace_log = TraceLog::GetInstance(); 2447 TraceLog* trace_log = TraceLog::GetInstance();
2448 trace_log->SetEnabled(CategoryFilter("*"), 2448 trace_log->SetEnabled(CategoryFilter("*"),
2449 TraceLog::RECORDING_MODE, 2449 TraceLog::RECORDING_MODE,
2450 TraceOptions()); 2450 TraceOptions());
2451 trace_log->logged_events_.reset( 2451 trace_log->logged_events_.reset(
2452 trace_log->CreateTraceBufferVectorOfSize(100)); 2452 trace_log->CreateTraceBufferVectorOfSize(100));
2453 do { 2453 do {
2454 TRACE_EVENT_BEGIN_WITH_ID_TID_AND_TIMESTAMP0( 2454 TRACE_EVENT_BEGIN_WITH_ID_TID_AND_TIMESTAMP0(
2455 "all", "with_timestamp", 0, 0, 2455 "all", "with_timestamp", 0, 0, TraceTicks::Now().ToInternalValue());
2456 TimeTicks::NowFromSystemTraceTime().ToInternalValue());
2457 TRACE_EVENT_END_WITH_ID_TID_AND_TIMESTAMP0( 2456 TRACE_EVENT_END_WITH_ID_TID_AND_TIMESTAMP0(
2458 "all", "with_timestamp", 0, 0, 2457 "all", "with_timestamp", 0, 0, TraceTicks::Now().ToInternalValue());
2459 TimeTicks::NowFromSystemTraceTime().ToInternalValue());
2460 } while (!trace_log->BufferIsFull()); 2458 } while (!trace_log->BufferIsFull());
2461 2459
2462 EndTraceAndFlush(); 2460 EndTraceAndFlush();
2463 2461
2464 const DictionaryValue* trace_full_metadata = NULL; 2462 const DictionaryValue* trace_full_metadata = NULL;
2465 2463
2466 trace_full_metadata = FindTraceEntry(trace_parsed_, 2464 trace_full_metadata = FindTraceEntry(trace_parsed_,
2467 "overflowed_at_ts"); 2465 "overflowed_at_ts");
2468 std::string phase; 2466 std::string phase;
2469 double buffer_limit_reached_timestamp = 0; 2467 double buffer_limit_reached_timestamp = 0;
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
2921 TRACE_EVENT0("b", "duration"); 2919 TRACE_EVENT0("b", "duration");
2922 } 2920 }
2923 2921
2924 EndTraceAndFlush(); 2922 EndTraceAndFlush();
2925 logging::SetLogMessageHandler(old_log_message_handler); 2923 logging::SetLogMessageHandler(old_log_message_handler);
2926 } 2924 }
2927 2925
2928 TEST_F(TraceEventTestFixture, TimeOffset) { 2926 TEST_F(TraceEventTestFixture, TimeOffset) {
2929 BeginTrace(); 2927 BeginTrace();
2930 // Let TraceLog timer start from 0. 2928 // Let TraceLog timer start from 0.
2931 TimeDelta time_offset = TimeTicks::NowFromSystemTraceTime() - TimeTicks(); 2929 TimeDelta time_offset = TraceTicks::Now() - TraceTicks();
2932 TraceLog::GetInstance()->SetTimeOffset(time_offset); 2930 TraceLog::GetInstance()->SetTimeOffset(time_offset);
2933 2931
2934 { 2932 {
2935 TRACE_EVENT0("all", "duration1"); 2933 TRACE_EVENT0("all", "duration1");
2936 TRACE_EVENT0("all", "duration2"); 2934 TRACE_EVENT0("all", "duration2");
2937 } 2935 }
2938 TRACE_EVENT_BEGIN_WITH_ID_TID_AND_TIMESTAMP0( 2936 TRACE_EVENT_BEGIN_WITH_ID_TID_AND_TIMESTAMP0(
2939 "all", "with_timestamp", 0, 0, 2937 "all", "with_timestamp", 0, 0, TraceTicks::Now().ToInternalValue());
2940 TimeTicks::NowFromSystemTraceTime().ToInternalValue());
2941 TRACE_EVENT_END_WITH_ID_TID_AND_TIMESTAMP0( 2938 TRACE_EVENT_END_WITH_ID_TID_AND_TIMESTAMP0(
2942 "all", "with_timestamp", 0, 0, 2939 "all", "with_timestamp", 0, 0, TraceTicks::Now().ToInternalValue());
2943 TimeTicks::NowFromSystemTraceTime().ToInternalValue());
2944 2940
2945 EndTraceAndFlush(); 2941 EndTraceAndFlush();
2946 DropTracedMetadataRecords(); 2942 DropTracedMetadataRecords();
2947 2943
2948 double end_time = static_cast<double>( 2944 double end_time = static_cast<double>(
2949 (TimeTicks::NowFromSystemTraceTime() - time_offset).ToInternalValue()); 2945 (TraceTicks::Now() - time_offset).ToInternalValue());
2950 double last_timestamp = 0; 2946 double last_timestamp = 0;
2951 for (size_t i = 0; i < trace_parsed_.GetSize(); ++i) { 2947 for (size_t i = 0; i < trace_parsed_.GetSize(); ++i) {
2952 const DictionaryValue* item; 2948 const DictionaryValue* item;
2953 EXPECT_TRUE(trace_parsed_.GetDictionary(i, &item)); 2949 EXPECT_TRUE(trace_parsed_.GetDictionary(i, &item));
2954 double timestamp; 2950 double timestamp;
2955 EXPECT_TRUE(item->GetDouble("ts", &timestamp)); 2951 EXPECT_TRUE(item->GetDouble("ts", &timestamp));
2956 EXPECT_GE(timestamp, last_timestamp); 2952 EXPECT_GE(timestamp, last_timestamp);
2957 EXPECT_LE(timestamp, end_time); 2953 EXPECT_LE(timestamp, end_time);
2958 last_timestamp = timestamp; 2954 last_timestamp = timestamp;
2959 } 2955 }
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
3075 EXPECT_EQ(original_option.record_mode, new_options.record_mode); 3071 EXPECT_EQ(original_option.record_mode, new_options.record_mode);
3076 EXPECT_EQ(original_option.enable_sampling, new_options.enable_sampling); 3072 EXPECT_EQ(original_option.enable_sampling, new_options.enable_sampling);
3077 EXPECT_EQ(original_option.enable_systrace, new_options.enable_systrace); 3073 EXPECT_EQ(original_option.enable_systrace, new_options.enable_systrace);
3078 } 3074 }
3079 } 3075 }
3080 } 3076 }
3081 } 3077 }
3082 3078
3083 } // namespace trace_event 3079 } // namespace trace_event
3084 } // namespace base 3080 } // namespace base
OLDNEW
« no previous file with comments | « base/trace_event/trace_event_impl.cc ('k') | cc/debug/lap_timer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698