summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-11 20:14:13 +0000
committerphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-11 20:14:13 +0000
commitafa5a314c7d3698c8065ba824e5700c2af211844 (patch)
tree3be3f505dd3d5609eaaae5c0189892fa30302885
parent1ecbf13615d89a0e0369cab2e70692d5b9a46341 (diff)
downloadchromium_src-afa5a314c7d3698c8065ba824e5700c2af211844.zip
chromium_src-afa5a314c7d3698c8065ba824e5700c2af211844.tar.gz
chromium_src-afa5a314c7d3698c8065ba824e5700c2af211844.tar.bz2
Reverting 6815.
Review URL: http://codereview.chromium.org/14006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6816 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/base_lib.scons2
-rw-r--r--base/test_file_util.h4
-rw-r--r--base/test_file_util_linux.cc5
-rw-r--r--base/test_file_util_mac.cc2
-rw-r--r--chrome/browser/safe_browsing/database_perftest.cc176
-rw-r--r--chrome/browser/safe_browsing/safe_browsing_database.h6
-rw-r--r--chrome/browser/visitedlink_perftest.cc4
-rw-r--r--chrome/chrome.scons2
-rw-r--r--chrome/test/perf/perftests.cc9
-rw-r--r--chrome/test/perf/perftests.scons68
-rw-r--r--chrome/tools/perf/flush_cache/flush_cache.cc6
-rw-r--r--net/disk_cache/disk_cache_perftest.cc101
12 files changed, 220 insertions, 165 deletions
diff --git a/base/base_lib.scons b/base/base_lib.scons
index 50e7b99..8f8fd0c 100644
--- a/base/base_lib.scons
+++ b/base/base_lib.scons
@@ -191,7 +191,6 @@ if env['PLATFORM'] == 'darwin':
'platform_thread_mac.mm',
'scoped_nsautorelease_pool.mm',
'sys_string_conversions_mac.mm',
- 'test_file_util_mac.cc',
'worker_pool_mac.mm',
])
@@ -208,7 +207,6 @@ if env['PLATFORM'] == 'posix':
'process_posix.cc',
'process_util_linux.cc',
'sys_string_conversions_linux.cc',
- 'test_file_util_linux.cc',
'worker_pool.cc',
])
diff --git a/base/test_file_util.h b/base/test_file_util.h
index 1ecaf29..3547d55 100644
--- a/base/test_file_util.h
+++ b/base/test_file_util.h
@@ -9,13 +9,11 @@
#include <string>
-class FilePath;
-
namespace file_util {
// Clear a specific file from the system cache. After this call, trying
// to access this file will result in a cold load from the hard drive.
-bool EvictFileFromSystemCache(const FilePath& file);
+bool EvictFileFromSystemCache(const wchar_t* file);
// Like CopyFileNoCache but recursively copies all files and subdirectories
// in the given input directory to the output directory. Any files in the
diff --git a/base/test_file_util_linux.cc b/base/test_file_util_linux.cc
index c1b3768..421d182 100644
--- a/base/test_file_util_linux.cc
+++ b/base/test_file_util_linux.cc
@@ -12,8 +12,9 @@
namespace file_util {
-bool EvictFileFromSystemCache(const FilePath& file) {
- int fd = open(file.value().c_str(), O_RDONLY);
+bool EvictFileFromSystemCache(const wchar_t* file) {
+ FilePath fpath = FilePath::FromWStringHack(file);
+ int fd = open(fpath.value().c_str(), O_RDONLY);
if (fd < 0)
return false;
if (fdatasync(fd) != 0)
diff --git a/base/test_file_util_mac.cc b/base/test_file_util_mac.cc
index 1dd8533..ebb13f3 100644
--- a/base/test_file_util_mac.cc
+++ b/base/test_file_util_mac.cc
@@ -8,7 +8,7 @@
namespace file_util {
-bool EvictFileFromSystemCache(const FilePath& file) {
+bool EvictFileFromSystemCache(const wchar_t* file) {
// TODO(port): Implement.
NOTIMPLEMENTED();
return false;
diff --git a/chrome/browser/safe_browsing/database_perftest.cc b/chrome/browser/safe_browsing/database_perftest.cc
index 0da2ffc..273bda4 100644
--- a/chrome/browser/safe_browsing/database_perftest.cc
+++ b/chrome/browser/safe_browsing/database_perftest.cc
@@ -5,26 +5,25 @@
#include <stdio.h>
#include <stdlib.h>
-#include <limits>
#include <set>
-#include "base/file_path.h"
#include "base/file_util.h"
#include "base/logging.h"
#include "base/path_service.h"
#include "base/perftimer.h"
-#include "base/rand_util.h"
-#include "base/scoped_ptr.h"
#include "base/string_util.h"
#include "base/test_file_util.h"
#include "chrome/browser/safe_browsing/safe_browsing_database.h"
-#include "chrome/browser/safe_browsing/safe_browsing_database_impl.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/sqlite_compiled_statement.h"
#include "chrome/common/sqlite_utils.h"
-#include "googleurl/src/gurl.h"
#include "testing/gtest/include/gtest/gtest.h"
+// These tests are slow, especially the ones that create databases. So disable
+// them by default.
+//#define SAFE_BROWSING_DATABASE_TESTS_ENABLED
+#ifdef SAFE_BROWSING_DATABASE_TESTS_ENABLED
+
namespace {
// Base class for a safebrowsing database. Derived classes can implement
@@ -36,27 +35,28 @@ class Database {
~Database() {
if (db_) {
+ statement_cache_.Cleanup();
sqlite3_close(db_);
db_ = NULL;
}
}
- bool Init(const FilePath& name, bool create) {
+ bool Init(const std::string& name, bool create) {
// get an empty file for the test DB
- FilePath filename;
+ std::wstring filename;
PathService::Get(base::DIR_TEMP, &filename);
- filename = filename.Append(name);
+ filename.push_back(FilePath::kSeparators[0]);
+ filename.append(ASCIIToWide(name));
if (create) {
- file_util::Delete(filename, false);
+ DeleteFile(filename.c_str());
} else {
- DLOG(INFO) << "evicting " << name.value() << " ...";
- file_util::EvictFileFromSystemCache(filename);
+ DLOG(INFO) << "evicting " << name << " ...";
+ file_util::EvictFileFromSystemCache(filename.c_str());
DLOG(INFO) << "... evicted";
}
- const std::string sqlite_path = WideToUTF8(filename.ToWStringHack());
- if (sqlite3_open(sqlite_path.c_str(), &db_) != SQLITE_OK)
+ if (sqlite3_open(WideToUTF8(filename).c_str(), &db_) != SQLITE_OK)
return false;
statement_cache_.set_db(db_);
@@ -197,7 +197,7 @@ class IndexedWithIDDatabase : public SimpleDatabase {
}
};
-} // namespace
+}
class SafeBrowsing: public testing::Test {
protected:
@@ -253,8 +253,7 @@ class SafeBrowsing: public testing::Test {
db_name_.append(count_start);
db_name_.append(db_->GetDBSuffix());
- FilePath path = FilePath::FromWStringHack(ASCIIToWide(db_name_));
- ASSERT_TRUE(db_->Init(path, type == WRITE));
+ ASSERT_TRUE(db_->Init(db_name_, type == WRITE));
if (type == WRITE) {
WriteEntries(size);
@@ -276,9 +275,10 @@ class SafeBrowsing: public testing::Test {
SQLTransaction transaction(db_->db());
transaction.Begin();
+ int inc = kint32max / count;
for (int i = 0; i < count; i++) {
- int hostkey = base::RandInt(std::numeric_limits<int>::min(),
- std::numeric_limits<int>::max());
+ int hostkey;
+ rand_s((unsigned int*)&hostkey);
ASSERT_TRUE(db_->Add(hostkey, prefixes, 1));
}
@@ -292,8 +292,8 @@ class SafeBrowsing: public testing::Test {
int64 total_ms = 0;
for (int i = 0; i < count; ++i) {
- int key = base::RandInt(std::numeric_limits<int>::min(),
- std::numeric_limits<int>::max());
+ int key;
+ rand_s((unsigned int*)&key);
PerfTimer timer;
@@ -332,75 +332,74 @@ class SafeBrowsing: public testing::Test {
std::string db_name_;
};
-TEST_F(SafeBrowsing, DISABLED_Write_100K) {
+TEST_F(SafeBrowsing, Write_100K) {
}
-TEST_F(SafeBrowsing, DISABLED_Read_100K) {
+TEST_F(SafeBrowsing, Read_100K) {
}
-TEST_F(SafeBrowsing, DISABLED_WriteIndexed_100K) {
+TEST_F(SafeBrowsing, WriteIndexed_100K) {
}
-TEST_F(SafeBrowsing, DISABLED_ReadIndexed_100K) {
+TEST_F(SafeBrowsing, ReadIndexed_100K) {
}
-TEST_F(SafeBrowsing, DISABLED_WriteIndexed_250K) {
+TEST_F(SafeBrowsing, WriteIndexed_250K) {
}
-TEST_F(SafeBrowsing, DISABLED_ReadIndexed_250K) {
+TEST_F(SafeBrowsing, ReadIndexed_250K) {
}
-TEST_F(SafeBrowsing, DISABLED_WriteIndexed_500K) {
+TEST_F(SafeBrowsing, WriteIndexed_500K) {
}
-TEST_F(SafeBrowsing, DISABLED_ReadIndexed_500K) {
+TEST_F(SafeBrowsing, ReadIndexed_500K) {
}
-TEST_F(SafeBrowsing, DISABLED_WriteIndexedWithID_250K) {
+TEST_F(SafeBrowsing, ReadIndexedWithID_250K) {
}
-TEST_F(SafeBrowsing, DISABLED_ReadIndexedWithID_250K) {
+TEST_F(SafeBrowsing, WriteIndexedWithID_250K) {
}
-TEST_F(SafeBrowsing, DISABLED_WriteIndexedWithID_500K) {
+TEST_F(SafeBrowsing, ReadIndexedWithID_500K) {
}
-TEST_F(SafeBrowsing, DISABLED_ReadIndexedWithID_500K) {
+TEST_F(SafeBrowsing, WriteIndexedWithID_500K) {
}
-TEST_F(SafeBrowsing, DISABLED_CountIndexed_250K) {
+TEST_F(SafeBrowsing, CountIndexed_250K) {
}
-TEST_F(SafeBrowsing, DISABLED_CountIndexed_500K) {
+TEST_F(SafeBrowsing, CountIndexed_500K) {
}
-TEST_F(SafeBrowsing, DISABLED_CountIndexedWithID_250K) {
+TEST_F(SafeBrowsing, CountIndexedWithID_250K) {
}
-TEST_F(SafeBrowsing, DISABLED_CountIndexedWithID_500K) {
+TEST_F(SafeBrowsing, CountIndexedWithID_500K) {
}
class SafeBrowsingDatabaseTest {
public:
- SafeBrowsingDatabaseTest(const FilePath& filename) {
+ SafeBrowsingDatabaseTest(const std::wstring& name) {
logging::InitLogging(
NULL, logging::LOG_ONLY_TO_SYSTEM_DEBUG_LOG,
logging::LOCK_LOG_FILE,
logging::DELETE_OLD_LOG_FILE);
- std::wstring tmp_path;
- PathService::Get(base::DIR_TEMP, &tmp_path);
- path_ = FilePath::FromWStringHack(tmp_path);
- path_ = path_.Append(filename);
+ PathService::Get(base::DIR_TEMP, &filename_);
+ filename_.push_back(FilePath::kSeparators[0]);
+ filename_.append(name);
}
void Create(int size) {
- file_util::Delete(path_, false);
+ DeleteFile(filename_.c_str());
- scoped_ptr<SafeBrowsingDatabase> database(SafeBrowsingDatabase::Create());
- database->SetSynchronous();
- EXPECT_TRUE(database->Init(path_.ToWStringHack(), NULL));
+ SafeBrowsingDatabase database;
+ database.set_synchronous();
+ EXPECT_TRUE(database.Init(filename_));
int chunk_id = 0;
int total_host_keys = size;
@@ -414,8 +413,7 @@ class SafeBrowsingDatabaseTest {
for (int j = 0; j < host_keys_per_chunk; ++j) {
SBChunkHost host;
- host.host = base::RandInt(std::numeric_limits<int>::min(),
- std::numeric_limits<int>::max());
+ rand_s((unsigned int*)&host.host);
host.entry = SBEntry::Create(SBEntry::ADD_PREFIX, 2);
host.entry->SetPrefixAt(0, 0x2425525);
host.entry->SetPrefixAt(1, 0x1536366);
@@ -424,37 +422,32 @@ class SafeBrowsingDatabaseTest {
}
}
- database->InsertChunks("goog-malware", chunks);
+ database.InsertChunks("goog-malware", chunks);
}
void Read(bool use_bloom_filter) {
int keys_to_read = 500;
- file_util::EvictFileFromSystemCache(path_);
+ file_util::EvictFileFromSystemCache(filename_.c_str());
- scoped_ptr<SafeBrowsingDatabase> database(SafeBrowsingDatabase::Create());
- database->SetSynchronous();
- EXPECT_TRUE(database->Init(path_.ToWStringHack(), NULL));
+ SafeBrowsingDatabase database;
+ database.set_synchronous();
+ EXPECT_TRUE(database.Init(filename_));
PerfTimer total_timer;
int64 db_ms = 0;
int keys_from_db = 0;
for (int i = 0; i < keys_to_read; ++i) {
- int key = base::RandInt(std::numeric_limits<int>::min(),
- std::numeric_limits<int>::max());
+ int key;
+ rand_s((unsigned int*)&key);
std::string url = StringPrintf("http://www.%d.com/blah.html", key);
std::string matching_list;
std::vector<SBPrefix> prefix_hits;
- std::vector<SBFullHashResult> full_hits;
GURL gurl(url);
- if (!use_bloom_filter || database->NeedToCheckUrl(gurl)) {
+ if (!use_bloom_filter || database.NeedToCheckUrl(gurl)) {
PerfTimer timer;
- database->ContainsUrl(gurl,
- &matching_list,
- &prefix_hits,
- &full_hits,
- base::Time::Now());
+ database.ContainsUrl(gurl, &matching_list, &prefix_hits);
int64 time_ms = timer.Elapsed().InMilliseconds();
@@ -467,80 +460,81 @@ class SafeBrowsingDatabaseTest {
int64 total_ms = total_timer.Elapsed().InMilliseconds();
- DLOG(INFO) << path_.BaseName().value() << " read " << keys_to_read <<
- " entries in " << total_ms << " ms. " << keys_from_db <<
- " keys were read from the db, with average read taking " <<
+ DLOG(INFO) << WideToASCII(file_util::GetFilenameFromPath(filename_)) <<
+ " read " << keys_to_read << " entries in " << total_ms << " ms. " <<
+ keys_from_db << " keys were read from the db, with average read taking " <<
db_ms / keys_from_db << " ms";
}
void BuildBloomFilter() {
- file_util::EvictFileFromSystemCache(path_);
- file_util::Delete(SafeBrowsingDatabase::BloomFilterFilename(
- path_.ToWStringHack()), false);
+ file_util::EvictFileFromSystemCache(filename_.c_str());
+ file_util::Delete(SafeBrowsingDatabase::BloomFilterFilename(filename_), false);
PerfTimer total_timer;
- scoped_ptr<SafeBrowsingDatabase> database(SafeBrowsingDatabase::Create());
- database->SetSynchronous();
- EXPECT_TRUE(database->Init(path_.ToWStringHack(), NULL));
+ SafeBrowsingDatabase database;
+ database.set_synchronous();
+ EXPECT_TRUE(database.Init(filename_));
int64 total_ms = total_timer.Elapsed().InMilliseconds();
- DLOG(INFO) << path_.BaseName().value() <<
+ DLOG(INFO) << WideToASCII(file_util::GetFilenameFromPath(filename_)) <<
" built bloom filter in " << total_ms << " ms.";
}
private:
- FilePath path_;
+ std::wstring filename_;
};
// Adds 100K host records.
-TEST(SafeBrowsingDatabase, DISABLED_FillUp100K) {
- SafeBrowsingDatabaseTest db(FilePath(FILE_PATH_LITERAL("SafeBrowsing100K")));
+TEST(SafeBrowsingDatabase, FillUp100K) {
+ SafeBrowsingDatabaseTest db(L"SafeBrowsing100K");
db.Create(100000);
}
// Adds 250K host records.
-TEST(SafeBrowsingDatabase, DISABLED_FillUp250K) {
- SafeBrowsingDatabaseTest db(FilePath(FILE_PATH_LITERAL("SafeBrowsing250K")));
+TEST(SafeBrowsingDatabase, FillUp250K) {
+ SafeBrowsingDatabaseTest db(L"SafeBrowsing250K");
db.Create(250000);
}
// Adds 500K host records.
-TEST(SafeBrowsingDatabase, DISABLED_FillUp500K) {
- SafeBrowsingDatabaseTest db(FilePath(FILE_PATH_LITERAL("SafeBrowsing500K")));
+TEST(SafeBrowsingDatabase, FillUp500K) {
+ SafeBrowsingDatabaseTest db(L"SafeBrowsing500K");
db.Create(500000);
}
// Reads 500 entries and prints the timing.
-TEST(SafeBrowsingDatabase, DISABLED_ReadFrom250K) {
- SafeBrowsingDatabaseTest db(FilePath(FILE_PATH_LITERAL("SafeBrowsing250K")));
+TEST(SafeBrowsingDatabase, ReadFrom250K) {
+ SafeBrowsingDatabaseTest db(L"SafeBrowsing250K");
db.Read(false);
}
-TEST(SafeBrowsingDatabase, DISABLED_ReadFrom500K) {
- SafeBrowsingDatabaseTest db(FilePath(FILE_PATH_LITERAL("SafeBrowsing500K")));
+TEST(SafeBrowsingDatabase, ReadFrom500K) {
+ SafeBrowsingDatabaseTest db(L"SafeBrowsing500K");
db.Read(false);
}
// Read 500 entries with a bloom filter and print the timing.
-TEST(SafeBrowsingDatabase, DISABLED_BloomReadFrom250K) {
- SafeBrowsingDatabaseTest db(FilePath(FILE_PATH_LITERAL("SafeBrowsing250K")));
+TEST(SafeBrowsingDatabase, BloomReadFrom250K) {
+ SafeBrowsingDatabaseTest db(L"SafeBrowsing250K");
db.Read(true);
}
-TEST(SafeBrowsingDatabase, DISABLED_BloomReadFrom500K) {
- SafeBrowsingDatabaseTest db(FilePath(FILE_PATH_LITERAL("SafeBrowsing500K")));
+TEST(SafeBrowsingDatabase, BloomReadFrom500K) {
+ SafeBrowsingDatabaseTest db(L"SafeBrowsing500K");
db.Read(true);
}
// Test how long bloom filter creation takes.
-TEST(SafeBrowsingDatabase, DISABLED_BuildBloomFilter250K) {
- SafeBrowsingDatabaseTest db(FilePath(FILE_PATH_LITERAL("SafeBrowsing250K")));
+TEST(SafeBrowsingDatabase, BuildBloomFilter250K) {
+ SafeBrowsingDatabaseTest db(L"SafeBrowsing250K");
db.BuildBloomFilter();
}
-TEST(SafeBrowsingDatabase, DISABLED_BuildBloomFilter500K) {
- SafeBrowsingDatabaseTest db(FilePath(FILE_PATH_LITERAL("SafeBrowsing500K")));
+TEST(SafeBrowsingDatabase, BuildBloomFilter500K) {
+ SafeBrowsingDatabaseTest db(L"SafeBrowsing500K");
db.BuildBloomFilter();
}
+
+#endif
diff --git a/chrome/browser/safe_browsing/safe_browsing_database.h b/chrome/browser/safe_browsing/safe_browsing_database.h
index 6e6612a..5e38763 100644
--- a/chrome/browser/safe_browsing/safe_browsing_database.h
+++ b/chrome/browser/safe_browsing/safe_browsing_database.h
@@ -89,9 +89,6 @@ class SafeBrowsingDatabase {
virtual std::wstring filename() const { return filename_; }
protected:
- friend class SafeBrowsingDatabaseTest;
- FRIEND_TEST(SafeBrowsingDatabase, HashCaching);
-
static std::wstring BloomFilterFilename(const std::wstring& db_filename);
// Load the bloom filter off disk, or generates one if it doesn't exist.
@@ -109,6 +106,9 @@ class SafeBrowsingDatabase {
// Measuring false positive rate. Call this each time we look in the filter.
virtual void IncrementBloomFilterReadCount() {}
+ // Full hash cache support.
+ FRIEND_TEST(SafeBrowsingDatabase, HashCaching);
+
typedef struct HashCacheEntry {
SBFullHash full_hash;
int list_id;
diff --git a/chrome/browser/visitedlink_perftest.cc b/chrome/browser/visitedlink_perftest.cc
index 3775fab..d589f92 100644
--- a/chrome/browser/visitedlink_perftest.cc
+++ b/chrome/browser/visitedlink_perftest.cc
@@ -6,7 +6,6 @@
#include <string>
#include <vector>
-#include "base/file_path.h"
#include "base/file_util.h"
#include "base/perftimer.h"
#include "base/shared_memory.h"
@@ -144,8 +143,7 @@ TEST_F(VisitedLink, TestLoad) {
for (int i = 0; i < load_count; i++)
{
// make sure the file has to be re-loaded
- file_util::EvictFileFromSystemCache(
- FilePath::FromWStringHack(std::wstring(db_name_)));
+ file_util::EvictFileFromSystemCache(db_name_.c_str());
// cold load (no OS cache, hopefully)
{
diff --git a/chrome/chrome.scons b/chrome/chrome.scons
index 78d63b8..a012047 100644
--- a/chrome/chrome.scons
+++ b/chrome/chrome.scons
@@ -93,6 +93,7 @@ if env['PLATFORM'] != 'win32':
'test/memory_test/memory_test.scons',
'test/mini_installer_test/mini_installer_test.scons',
'test/page_cycler/page_cycler_tests.scons',
+ 'test/perf/perftests.scons',
'test/plugin/plugin_tests.scons',
'test/reliability/reliability_tests.scons',
'test/security_tests/security_tests.scons',
@@ -102,6 +103,7 @@ if env['PLATFORM'] != 'win32':
'test/ui/ui_tests.scons',
'tools/convert_dict/convert_dict.scons',
'tools/crash_service/crash_service.scons',
+ 'tools/perf/flush_cache/flush_cache.scons',
'tools/profiles/generate_profile.scons',
]
sconscript_files = list(set(sconscript_files) - set(remove_files))
diff --git a/chrome/test/perf/perftests.cc b/chrome/test/perf/perftests.cc
index 18d92aa..3e67a6b 100644
--- a/chrome/test/perf/perftests.cc
+++ b/chrome/test/perf/perftests.cc
@@ -2,9 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/at_exit.h"
-#include "base/command_line.h"
-#include "base/debug_util.h"
#include "base/message_loop.h"
#include "base/perftimer.h"
#include "base/process_util.h"
@@ -14,9 +11,7 @@
// TODO(darin): share code with base/run_all_perftests.cc
int main(int argc, char **argv) {
- base::AtExitManager exit_manager;
base::EnableTerminationOnHeapCorruption();
- CommandLine::SetArgcArgv(argc, argv);
chrome::RegisterPathProvider();
MessageLoop main_message_loop;
@@ -48,8 +43,8 @@ int main(int argc, char **argv) {
// 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 (!DebugUtil::BeingDebugged()) {
- base::RaiseProcessToHighPriority();
+ if (!IsDebuggerPresent()) {
+ SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
}
int result = RUN_ALL_TESTS();
diff --git a/chrome/test/perf/perftests.scons b/chrome/test/perf/perftests.scons
index c089027..d93f4a6 100644
--- a/chrome/test/perf/perftests.scons
+++ b/chrome/test/perf/perftests.scons
@@ -1,22 +1,29 @@
-# Copyright (c) 2008 The Chromium Authors. All rights reserved.
+# Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-__doc__ = """
-Configuration for building the perf_tests{,.exe} executable.
-"""
-
Import('env')
env = env.Clone()
env.ApplySConscript([
+ '$BASE_DIR/gfx/using_base_gfx.scons',
'$BASE_DIR/using_base.scons',
- '$NET_DIR/using_net.scons',
+ '$BZIP2_DIR/using_bzip2.scons',
+ '$CHROME_DIR/third_party/hunspell/using_hunspell.scons',
'$CHROME_SRC_DIR/build/using_googleurl.scons',
+ '$CHROME_SRC_DIR/build/using_v8.scons',
'$GTEST_DIR/../using_gtest.scons',
'$ICU38_DIR/using_icu38.scons',
+ '$LIBJPEG_DIR/using_libjpeg.scons',
+ '$LIBPNG_DIR/using_libpng.scons',
+ '$LIBXML_DIR/using_libxml.scons',
+ '$LIBXSLT_DIR/using_libxslt.scons',
'$MODP_B64_DIR/using_modp_b64.scons',
+ '$NET_DIR/using_net.scons',
+ '$SDCH_DIR/using_sdch.scons',
+ '$SKIA_DIR/using_skia.scons',
+ '$ZLIB_DIR/using_zlib.scons',
])
env.Prepend(
@@ -24,16 +31,35 @@ env.Prepend(
'PERF_TEST',
],
LIBS = [
+ 'activex_shim',
'browser',
+ 'browser_views',
'common',
+ 'debugger',
+ 'default_plugin',
+ 'glue',
+ 'JavaScriptCore_pcre',
+ 'plugin',
+ 'port',
+ 'renderer',
'sqlite',
+ 'util',
+ 'v8_snapshot',
+ 'V8Bindings',
+ 'views',
+ 'WebCore',
+ 'WTF',
],
)
-if env['PLATFORM'] in ('posix', 'darwin'):
- env.SConscript([
- '$LIBEVENT_DIR/using_libevent.scons',
- ], {'env':env})
+if env['PLATFORM'] == 'win32':
+ env.Prepend(
+ LIBS = [
+ 'rpcrt4',
+ 'shlwapi',
+ 'winmm',
+ ],
+ )
input_files = [
'perftests.cc',
@@ -45,24 +71,4 @@ input_files = [
'$CHROME_DIR/common/json_value_serializer_perftest.cc',
]
-if env['PLATFORM'] == 'win32':
- env.Prepend(
- LIBS = [
- 'rpcrt4',
- 'shlwapi',
- 'winmm',
- ]
- )
-
-if env['PLATFORM'] != 'win32':
- # TODO(port): Port these files.
- remove_files = [
- 'url_parse_perftest.cc',
- '$CHROME_DIR/browser/visitedlink_master$OBJSUFFIX',
- '$CHROME_DIR/browser/visitedlink_perftest.cc',
- ]
- for file in remove_files:
- input_files.remove(file)
-
-if env['PLATFORM'] in ('posix', 'win32'):
- env.ChromeTestProgram('perf_tests', input_files)
+env.ChromeTestProgram('perf_tests', input_files)
diff --git a/chrome/tools/perf/flush_cache/flush_cache.cc b/chrome/tools/perf/flush_cache/flush_cache.cc
index e178da4e..d6ba850 100644
--- a/chrome/tools/perf/flush_cache/flush_cache.cc
+++ b/chrome/tools/perf/flush_cache/flush_cache.cc
@@ -2,10 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// This little program attempts to flush the system cache for some files.
+// This little program attempts to flush the disk cache for some files.
// It's useful for testing Chrome with a cold database.
-#include "base/file_path.h"
#include "base/string_piece.h"
#include "base/process_util.h"
#include "base/sys_string_conversions.h"
@@ -21,8 +20,7 @@ int main(int argc, const char* argv[]) {
for (int i = 1; i < argc; ++i) {
std::wstring filename = base::SysNativeMBToWide(argv[i]);
- FilePath path = FilePath::FromWStringHack(filename);
- if (!file_util::EvictFileFromSystemCache(path)) {
+ if (!file_util::EvictFileFromSystemCache(filename.c_str())) {
fprintf(stderr, "Failed to evict %s from cache -- is it a directory?\n",
argv[i]);
}
diff --git a/net/disk_cache/disk_cache_perftest.cc b/net/disk_cache/disk_cache_perftest.cc
index 08d0374..ecae2c3 100644
--- a/net/disk_cache/disk_cache_perftest.cc
+++ b/net/disk_cache/disk_cache_perftest.cc
@@ -2,14 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <fcntl.h>
+
#include <string>
#include "base/basictypes.h"
-#include "base/file_path.h"
#include "base/file_util.h"
#include "base/perftimer.h"
+#if defined(OS_WIN)
+#include "base/scoped_handle.h"
+#endif
#include "base/string_util.h"
-#include "base/test_file_util.h"
#include "base/timer.h"
#include "net/base/net_errors.h"
#include "net/disk_cache/block_files.h"
@@ -29,6 +32,62 @@ typedef PlatformTest DiskCacheTest;
namespace {
+bool EvictFileFromSystemCache(const wchar_t* name) {
+#if defined(OS_WIN)
+ // Overwrite it with no buffering.
+ ScopedHandle file(CreateFile(name, GENERIC_READ | GENERIC_WRITE,
+ FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
+ OPEN_EXISTING, FILE_FLAG_NO_BUFFERING, NULL));
+ if (!file.IsValid())
+ return false;
+
+ // Execute in chunks. It could be optimized. We want to do few of these since
+ // these opterations will be slow without the cache.
+ char buffer[128 * 1024];
+ int total_bytes = 0;
+ DWORD bytes_read;
+ for (;;) {
+ if (!ReadFile(file, buffer, sizeof(buffer), &bytes_read, NULL))
+ return false;
+ if (bytes_read == 0)
+ break;
+
+ bool final = false;
+ if (bytes_read < sizeof(buffer))
+ final = true;
+
+ DWORD to_write = final ? sizeof(buffer) : bytes_read;
+
+ DWORD actual;
+ SetFilePointer(file, total_bytes, 0, FILE_BEGIN);
+ if (!WriteFile(file, buffer, to_write, &actual, NULL))
+ return false;
+ total_bytes += bytes_read;
+
+ if (final) {
+ SetFilePointer(file, total_bytes, 0, FILE_BEGIN);
+ SetEndOfFile(file);
+ break;
+ }
+ }
+ return true;
+#elif defined(OS_LINUX)
+ int fd = open(WideToUTF8(std::wstring(name)).c_str(), O_RDONLY);
+ if (fd < 0)
+ return false;
+ if (fdatasync(fd) != 0)
+ return false;
+ if (posix_fadvise(fd, 0, 0, POSIX_FADV_DONTNEED) != 0)
+ return false;
+ close(fd);
+ return true;
+#else
+ // TODO(port): Mac has its own way to do this.
+ NOTIMPLEMENTED();
+ return false;
+#endif
+}
+
struct TestEntry {
std::string key;
int data_len;
@@ -155,10 +214,9 @@ TEST_F(DiskCacheTest, Hash) {
TEST_F(DiskCacheTest, CacheBackendPerformance) {
MessageLoopForIO message_loop;
- std::wstring path_wstring = GetCachePath();
- ASSERT_TRUE(DeleteCache(path_wstring.c_str()));
- disk_cache::Backend* cache = disk_cache::CreateCacheBackend(path_wstring,
- false, 0);
+ std::wstring path = GetCachePath();
+ ASSERT_TRUE(DeleteCache(path.c_str()));
+ disk_cache::Backend* cache = disk_cache::CreateCacheBackend(path, false, 0);
ASSERT_TRUE(NULL != cache);
int seed = static_cast<int>(Time::Now().ToInternalValue());
@@ -173,20 +231,27 @@ TEST_F(DiskCacheTest, CacheBackendPerformance) {
MessageLoop::current()->RunAllPending();
delete cache;
- FilePath path = FilePath::FromWStringHack(path_wstring);
+ std::wstring filename(path);
+ file_util::AppendToPath(&filename, L"index");
+ ASSERT_TRUE(EvictFileFromSystemCache(filename.c_str()));
+
+ filename = path;
+ file_util::AppendToPath(&filename, L"data_0");
+ ASSERT_TRUE(EvictFileFromSystemCache(filename.c_str()));
+
+ filename = path;
+ file_util::AppendToPath(&filename, L"data_1");
+ ASSERT_TRUE(EvictFileFromSystemCache(filename.c_str()));
+
+ filename = path;
+ file_util::AppendToPath(&filename, L"data_2");
+ ASSERT_TRUE(EvictFileFromSystemCache(filename.c_str()));
- ASSERT_TRUE(file_util::EvictFileFromSystemCache(
- path.Append(FILE_PATH_LITERAL("index"))));
- ASSERT_TRUE(file_util::EvictFileFromSystemCache(
- path.Append(FILE_PATH_LITERAL("data_0"))));
- ASSERT_TRUE(file_util::EvictFileFromSystemCache(
- path.Append(FILE_PATH_LITERAL("data_1"))));
- ASSERT_TRUE(file_util::EvictFileFromSystemCache(
- path.Append(FILE_PATH_LITERAL("data_2"))));
- ASSERT_TRUE(file_util::EvictFileFromSystemCache(
- path.Append(FILE_PATH_LITERAL("data_3"))));
+ filename = path;
+ file_util::AppendToPath(&filename, L"data_3");
+ ASSERT_TRUE(EvictFileFromSystemCache(filename.c_str()));
- cache = disk_cache::CreateCacheBackend(path_wstring, false, 0);
+ cache = disk_cache::CreateCacheBackend(path, false, 0);
ASSERT_TRUE(NULL != cache);
ret = TimeRead(num_entries, cache, entries, true);