summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordarin@google.com <darin@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-27 04:58:51 +0000
committerdarin@google.com <darin@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-27 04:58:51 +0000
commitb1d1c87e0639f237d9d19a4f3bc599a00121b89f (patch)
tree31412abf6ee463d1bd6ba743530479343a759659
parent6ebe3fc0530639459b70413724db71f734c99422 (diff)
downloadchromium_src-b1d1c87e0639f237d9d19a4f3bc599a00121b89f.zip
chromium_src-b1d1c87e0639f237d9d19a4f3bc599a00121b89f.tar.gz
chromium_src-b1d1c87e0639f237d9d19a4f3bc599a00121b89f.tar.bz2
Fix the net_perftests to work again.
Since only one test needed a MessageLoop, I decided to only give that single test a MessageLoop. I used a MessageLoopForIO (subclass of MessageLoop) for future use when the disk cache leverages MessageLoopForIO for asynchronous IO. TBR=rvargas git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1428 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/run_all_perftests.cc51
-rw-r--r--net/base/run_all_unittests.cc2
-rw-r--r--net/disk_cache/disk_cache_perftest.cc2
3 files changed, 32 insertions, 23 deletions
diff --git a/base/run_all_perftests.cc b/base/run_all_perftests.cc
index 8e62c53..967aeb9 100644
--- a/base/run_all_perftests.cc
+++ b/base/run_all_perftests.cc
@@ -4,32 +4,39 @@
#include <windows.h>
-#include "base/at_exit.h"
#include "base/command_line.h"
#include "base/perftimer.h"
#include "base/string_util.h"
#include "base/test_suite.h"
+class PerfTestSuite : public TestSuite {
+ public:
+ PerfTestSuite(int argc, char** argv) : TestSuite(argc, argv) {
+ }
+
+ virtual void Initialize() {
+ // Initialize the perf timer log
+ std::string log_file =
+ WideToUTF8(CommandLine().GetSwitchValue(L"log-file"));
+ if (log_file.empty())
+ log_file = "perf_test.log";
+ ASSERT_TRUE(InitPerfLog(log_file.c_str()));
+
+ // Raise to high priority to have more precise measurements. Since we don't
+ // aim at 1% precision, it is not necessary to run at realtime level.
+ if (!IsDebuggerPresent())
+ SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
+
+ TestSuite::Initialize();
+ }
+
+ virtual void Shutdown() {
+ TestSuite::Shutdown();
+
+ FinalizePerfLog();
+ }
+};
+
int main(int argc, char** argv) {
- // Some tests may use base::Singleton<>, thus we need to instanciate
- // the AtExitManager or else we will leak objects.
- base::AtExitManager at_exit_manager;
-
- // Initialize the perf timer log
- std::string log_file =
- WideToUTF8(CommandLine().GetSwitchValue(L"log-file"));
- if (log_file.empty())
- log_file = "perf_test.log";
- ASSERT_TRUE(InitPerfLog(log_file.c_str()));
-
- // Raise to high priority to have more precise measurements. Since we don't
- // aim at 1% precision, it is not necessary to run at realtime level.
- if (!IsDebuggerPresent())
- SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
-
- int rv = TestSuite(argc, argv).Run();
-
- FinalizePerfLog();
- return rv;
+ return PerfTestSuite(argc, argv).Run();
}
-
diff --git a/net/base/run_all_unittests.cc b/net/base/run_all_unittests.cc
index a1bae81..f5c1419b 100644
--- a/net/base/run_all_unittests.cc
+++ b/net/base/run_all_unittests.cc
@@ -41,7 +41,7 @@ class NetTestSuite : public TestSuite {
message_loop_.reset(new MessageLoopForIO());
}
- virtual void CleanUp() {
+ virtual void Shutdown() {
// We want to destroy this here before the TestSuite continues to tear down
// the environment.
message_loop_.reset();
diff --git a/net/disk_cache/disk_cache_perftest.cc b/net/disk_cache/disk_cache_perftest.cc
index 483a824..e902ff0 100644
--- a/net/disk_cache/disk_cache_perftest.cc
+++ b/net/disk_cache/disk_cache_perftest.cc
@@ -176,6 +176,8 @@ TEST(DiskCacheTest, Hash) {
}
TEST(DiskCacheTest, CacheBackendPerformance) {
+ MessageLoopForIO message_loop;
+
std::wstring path = GetCachePath();
ASSERT_TRUE(DeleteCache(path.c_str()));
disk_cache::Backend* cache = disk_cache::CreateCacheBackend(path, false, 0);