summaryrefslogtreecommitdiffstats
path: root/base/stats_table_unittest.cc
diff options
context:
space:
mode:
authorevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-23 23:53:40 +0000
committerevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-23 23:53:40 +0000
commit88bfaa28ba1784c9cad2036a6a46560a2e6ee34e (patch)
tree0b99e424571f3c26ddd091a9986d1bac3fb8e03e /base/stats_table_unittest.cc
parent0207709de447c9a1871d0ecb7c29c283200a82d8 (diff)
downloadchromium_src-88bfaa28ba1784c9cad2036a6a46560a2e6ee34e.zip
chromium_src-88bfaa28ba1784c9cad2036a6a46560a2e6ee34e.tar.gz
chromium_src-88bfaa28ba1784c9cad2036a6a46560a2e6ee34e.tar.bz2
base_unittests: Turn down the sleeps on the stats table tests.
These tests are over 20% of the time taken by base_unittests. I don't think making these sleeps shorter should affect their reliability too much. BUG=10611 Review URL: http://codereview.chromium.org/3474009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@60385 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/stats_table_unittest.cc')
-rw-r--r--base/stats_table_unittest.cc38
1 files changed, 23 insertions, 15 deletions
diff --git a/base/stats_table_unittest.cc b/base/stats_table_unittest.cc
index d47a7b1..4fd79b5 100644
--- a/base/stats_table_unittest.cc
+++ b/base/stats_table_unittest.cc
@@ -75,7 +75,7 @@ const std::string kCounterDecrement = "CounterDecrement";
// decremented by even threads.
const std::string kCounterMixed = "CounterMixed";
// The number of thread loops that we will do.
-const int kThreadLoops = 1000;
+const int kThreadLoops = 100;
class StatsTableThread : public base::SimpleThread {
public:
@@ -319,17 +319,21 @@ TEST_F(StatsTableTest, StatsCounterTimer) {
EXPECT_TRUE(bar.start_time().is_null());
EXPECT_TRUE(bar.stop_time().is_null());
+ const int kRunMs = 100;
+
// Do some timing.
bar.Start();
- PlatformThread::Sleep(500);
+ PlatformThread::Sleep(kRunMs);
bar.Stop();
- EXPECT_LE(500, table.GetCounterValue("t:bar"));
+ EXPECT_GT(table.GetCounterValue("t:bar"), 0);
+ EXPECT_LE(kRunMs, table.GetCounterValue("t:bar"));
// Verify that timing again is additive.
bar.Start();
- PlatformThread::Sleep(500);
+ PlatformThread::Sleep(kRunMs);
bar.Stop();
- EXPECT_LE(1000, table.GetCounterValue("t:bar"));
+ EXPECT_GT(table.GetCounterValue("t:bar"), 0);
+ EXPECT_LE(kRunMs * 2, table.GetCounterValue("t:bar"));
}
// Test some basic StatsRate operations
@@ -348,19 +352,21 @@ TEST_F(StatsTableTest, StatsRate) {
EXPECT_EQ(0, table.GetCounterValue("c:baz"));
EXPECT_EQ(0, table.GetCounterValue("t:baz"));
+ const int kRunMs = 100;
+
// Do some timing.
baz.Start();
- PlatformThread::Sleep(500);
+ PlatformThread::Sleep(kRunMs);
baz.Stop();
EXPECT_EQ(1, table.GetCounterValue("c:baz"));
- EXPECT_LE(500, table.GetCounterValue("t:baz"));
+ EXPECT_LE(kRunMs, table.GetCounterValue("t:baz"));
// Verify that timing again is additive.
baz.Start();
- PlatformThread::Sleep(500);
+ PlatformThread::Sleep(kRunMs);
baz.Stop();
EXPECT_EQ(2, table.GetCounterValue("c:baz"));
- EXPECT_LE(1000, table.GetCounterValue("t:baz"));
+ EXPECT_LE(kRunMs * 2, table.GetCounterValue("t:baz"));
}
// Test some basic StatsScope operations
@@ -381,24 +387,26 @@ TEST_F(StatsTableTest, StatsScope) {
EXPECT_EQ(0, table.GetCounterValue("t:bar"));
EXPECT_EQ(0, table.GetCounterValue("c:bar"));
+ const int kRunMs = 100;
+
// Try a scope.
{
StatsScope<StatsCounterTimer> timer(foo);
StatsScope<StatsRate> timer2(bar);
- PlatformThread::Sleep(500);
+ PlatformThread::Sleep(kRunMs);
}
- EXPECT_LE(500, table.GetCounterValue("t:foo"));
- EXPECT_LE(500, table.GetCounterValue("t:bar"));
+ EXPECT_LE(kRunMs, table.GetCounterValue("t:foo"));
+ EXPECT_LE(kRunMs, 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(500);
+ PlatformThread::Sleep(kRunMs);
}
- EXPECT_LE(1000, table.GetCounterValue("t:foo"));
- EXPECT_LE(1000, table.GetCounterValue("t:bar"));
+ EXPECT_LE(kRunMs * 2, table.GetCounterValue("t:foo"));
+ EXPECT_LE(kRunMs * 2, table.GetCounterValue("t:bar"));
EXPECT_EQ(2, table.GetCounterValue("c:bar"));
DeleteShmem(kTableName);