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

Side by Side Diff: base/tracked_objects_unittest.cc

Issue 8502001: Switch to using an intergral type for durations inside profiler (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 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 | Annotate | Revision Log
« no previous file with comments | « base/tracked_objects.cc ('k') | no next file » | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // Test of classes in the tracked_objects.h classes. 5 // Test of classes in the tracked_objects.h classes.
6 6
7 #include "base/tracked_objects.h" 7 #include "base/tracked_objects.h"
8 8
9 #include "base/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 // The births were at the same location as the one known death. 111 // The births were at the same location as the one known death.
112 EXPECT_EQ(birth_map.begin()->second, death_map.begin()->first); 112 EXPECT_EQ(birth_map.begin()->second, death_map.begin()->first);
113 } 113 }
114 114
115 TEST_F(TrackedObjectsTest, DeathDataTest) { 115 TEST_F(TrackedObjectsTest, DeathDataTest) {
116 if (!ThreadData::InitializeAndSetTrackingStatus(true)) 116 if (!ThreadData::InitializeAndSetTrackingStatus(true))
117 return; 117 return;
118 118
119 scoped_ptr<DeathData> data(new DeathData()); 119 scoped_ptr<DeathData> data(new DeathData());
120 ASSERT_NE(data, reinterpret_cast<DeathData*>(NULL)); 120 ASSERT_NE(data, reinterpret_cast<DeathData*>(NULL));
121 EXPECT_EQ(data->run_duration(), Duration()); 121 EXPECT_EQ(data->run_duration(), 0);
122 EXPECT_EQ(data->queue_duration(), Duration()); 122 EXPECT_EQ(data->queue_duration(), 0);
123 EXPECT_EQ(data->AverageMsRunDuration(), 0); 123 EXPECT_EQ(data->AverageMsRunDuration(), 0);
124 EXPECT_EQ(data->AverageMsQueueDuration(), 0); 124 EXPECT_EQ(data->AverageMsQueueDuration(), 0);
125 EXPECT_EQ(data->count(), 0); 125 EXPECT_EQ(data->count(), 0);
126 126
127 int run_ms = 42; 127 DurationInt run_ms = 42;
128 int queue_ms = 8; 128 DurationInt queue_ms = 8;
129 129
130 Duration run_duration = Duration().FromMilliseconds(run_ms); 130 data->RecordDeath(queue_ms, run_ms);
131 Duration queue_duration = Duration().FromMilliseconds(queue_ms); 131 EXPECT_EQ(data->run_duration(), run_ms);
132 data->RecordDeath(queue_duration, run_duration); 132 EXPECT_EQ(data->queue_duration(), queue_ms);
133 EXPECT_EQ(data->run_duration(), run_duration);
134 EXPECT_EQ(data->queue_duration(), queue_duration);
135 EXPECT_EQ(data->AverageMsRunDuration(), run_ms); 133 EXPECT_EQ(data->AverageMsRunDuration(), run_ms);
136 EXPECT_EQ(data->AverageMsQueueDuration(), queue_ms); 134 EXPECT_EQ(data->AverageMsQueueDuration(), queue_ms);
137 EXPECT_EQ(data->count(), 1); 135 EXPECT_EQ(data->count(), 1);
138 136
139 data->RecordDeath(queue_duration, run_duration); 137 data->RecordDeath(queue_ms, run_ms);
140 EXPECT_EQ(data->run_duration(), run_duration + run_duration); 138 EXPECT_EQ(data->run_duration(), run_ms + run_ms);
141 EXPECT_EQ(data->queue_duration(), queue_duration + queue_duration); 139 EXPECT_EQ(data->queue_duration(), queue_ms + queue_ms);
142 EXPECT_EQ(data->AverageMsRunDuration(), run_ms); 140 EXPECT_EQ(data->AverageMsRunDuration(), run_ms);
143 EXPECT_EQ(data->AverageMsQueueDuration(), queue_ms); 141 EXPECT_EQ(data->AverageMsQueueDuration(), queue_ms);
144 EXPECT_EQ(data->count(), 2); 142 EXPECT_EQ(data->count(), 2);
145 143
146 scoped_ptr<base::DictionaryValue> dictionary(data->ToValue()); 144 scoped_ptr<base::DictionaryValue> dictionary(data->ToValue());
147 int integer; 145 int integer;
148 EXPECT_TRUE(dictionary->GetInteger("run_ms", &integer)); 146 EXPECT_TRUE(dictionary->GetInteger("run_ms", &integer));
149 EXPECT_EQ(integer, 2 * run_ms); 147 EXPECT_EQ(integer, 2 * run_ms);
150 EXPECT_TRUE(dictionary->GetInteger("queue_ms", &integer)); 148 EXPECT_TRUE(dictionary->GetInteger("queue_ms", &integer));
151 EXPECT_EQ(integer, 2 * queue_ms); 149 EXPECT_EQ(integer, 2 * queue_ms);
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 "\"line_number\":999" 627 "\"line_number\":999"
630 "}" 628 "}"
631 "}" 629 "}"
632 "]" 630 "]"
633 "}"; 631 "}";
634 EXPECT_EQ(one_line_result, json); 632 EXPECT_EQ(one_line_result, json);
635 } 633 }
636 634
637 635
638 } // namespace tracked_objects 636 } // namespace tracked_objects
OLDNEW
« no previous file with comments | « base/tracked_objects.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698