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

Unified Diff: base/metrics/stats_table_unittest.cc

Issue 9056001: Update Sleep() calls in metrics tests to use TimeDelta instead of int. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Give duration variable a better name. Created 9 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/metrics/stats_table_unittest.cc
diff --git a/base/metrics/stats_table_unittest.cc b/base/metrics/stats_table_unittest.cc
index 32484a61b67f96566b19ef965737c31c2bb380c1..ea0b9d4d80d095971fcddd05ff76ca3dd5e206e3 100644
--- a/base/metrics/stats_table_unittest.cc
+++ b/base/metrics/stats_table_unittest.cc
@@ -101,7 +101,7 @@ void StatsTableThread::Run() {
mixed_counter.Decrement();
else
mixed_counter.Increment();
- PlatformThread::Sleep(index % 10); // short wait
+ PlatformThread::Sleep(TimeDelta::FromMilliseconds(index % 10));
}
}
@@ -180,7 +180,7 @@ MULTIPROCESS_TEST_MAIN(StatsTableMultipleProcessMain) {
lucky13_counter.Set(1313);
increment_counter.Increment();
decrement_counter.Decrement();
- PlatformThread::Sleep(index % 10); // short wait
+ PlatformThread::Sleep(TimeDelta::FromMilliseconds(index % 10));
}
return 0;
}
@@ -315,21 +315,21 @@ TEST_F(StatsTableTest, StatsCounterTimer) {
EXPECT_TRUE(bar.start_time().is_null());
EXPECT_TRUE(bar.stop_time().is_null());
- const int kRunMs = 100;
+ const TimeDelta kDuration = TimeDelta::FromMilliseconds(100);
// Do some timing.
bar.Start();
- PlatformThread::Sleep(kRunMs);
+ PlatformThread::Sleep(kDuration);
bar.Stop();
EXPECT_GT(table.GetCounterValue("t:bar"), 0);
- EXPECT_LE(kRunMs, table.GetCounterValue("t:bar"));
+ EXPECT_LE(kDuration.InMilliseconds(), table.GetCounterValue("t:bar"));
// Verify that timing again is additive.
bar.Start();
- PlatformThread::Sleep(kRunMs);
+ PlatformThread::Sleep(kDuration);
bar.Stop();
EXPECT_GT(table.GetCounterValue("t:bar"), 0);
- EXPECT_LE(kRunMs * 2, table.GetCounterValue("t:bar"));
+ EXPECT_LE(kDuration.InMilliseconds() * 2, table.GetCounterValue("t:bar"));
}
// Test some basic StatsRate operations
@@ -348,21 +348,21 @@ TEST_F(StatsTableTest, StatsRate) {
EXPECT_EQ(0, table.GetCounterValue("c:baz"));
EXPECT_EQ(0, table.GetCounterValue("t:baz"));
- const int kRunMs = 100;
+ const TimeDelta kDuration = TimeDelta::FromMilliseconds(100);
// Do some timing.
baz.Start();
- PlatformThread::Sleep(kRunMs);
+ PlatformThread::Sleep(kDuration);
baz.Stop();
EXPECT_EQ(1, table.GetCounterValue("c:baz"));
- EXPECT_LE(kRunMs, table.GetCounterValue("t:baz"));
+ EXPECT_LE(kDuration.InMilliseconds(), table.GetCounterValue("t:baz"));
// Verify that timing again is additive.
baz.Start();
- PlatformThread::Sleep(kRunMs);
+ PlatformThread::Sleep(kDuration);
baz.Stop();
EXPECT_EQ(2, table.GetCounterValue("c:baz"));
- EXPECT_LE(kRunMs * 2, table.GetCounterValue("t:baz"));
+ EXPECT_LE(kDuration.InMilliseconds() * 2, table.GetCounterValue("t:baz"));
}
// Test some basic StatsScope operations
@@ -383,26 +383,26 @@ TEST_F(StatsTableTest, StatsScope) {
EXPECT_EQ(0, table.GetCounterValue("t:bar"));
EXPECT_EQ(0, table.GetCounterValue("c:bar"));
- const int kRunMs = 100;
+ const TimeDelta kDuration = TimeDelta::FromMilliseconds(100);
// Try a scope.
{
StatsScope<StatsCounterTimer> timer(foo);
StatsScope<StatsRate> timer2(bar);
- PlatformThread::Sleep(kRunMs);
+ PlatformThread::Sleep(kDuration);
}
- EXPECT_LE(kRunMs, table.GetCounterValue("t:foo"));
- EXPECT_LE(kRunMs, table.GetCounterValue("t:bar"));
+ EXPECT_LE(kDuration.InMilliseconds(), table.GetCounterValue("t:foo"));
+ EXPECT_LE(kDuration.InMilliseconds(), table.GetCounterValue("t:bar"));
EXPECT_EQ(1, table.GetCounterValue("c:bar"));
// Try a second scope.
{
StatsScope<StatsCounterTimer> timer(foo);
StatsScope<StatsRate> timer2(bar);
- PlatformThread::Sleep(kRunMs);
+ PlatformThread::Sleep(kDuration);
}
- EXPECT_LE(kRunMs * 2, table.GetCounterValue("t:foo"));
- EXPECT_LE(kRunMs * 2, table.GetCounterValue("t:bar"));
+ EXPECT_LE(kDuration.InMilliseconds() * 2, table.GetCounterValue("t:foo"));
+ EXPECT_LE(kDuration.InMilliseconds() * 2, table.GetCounterValue("t:bar"));
EXPECT_EQ(2, table.GetCounterValue("c:bar"));
DeleteShmem(kTableName);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698