summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorevanm@google.com <evanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-13 18:36:42 +0000
committerevanm@google.com <evanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-13 18:36:42 +0000
commitb03b09278bdea7a21868403de2ab027ef8e5b19b (patch)
treeae310e500ce0522ec8ff4c9b64226e81de37b319 /net
parent628da89f7ff111bd9937ee93544866f5d076298a (diff)
downloadchromium_src-b03b09278bdea7a21868403de2ab027ef8e5b19b.zip
chromium_src-b03b09278bdea7a21868403de2ab027ef8e5b19b.tar.gz
chromium_src-b03b09278bdea7a21868403de2ab027ef8e5b19b.tar.bz2
This makes net_perftests build and run on Linux.
BUG=3065 Review URL: http://codereview.chromium.org/6080 Patch from Paweł Hajdan jr <phajdan.jr@gmail.com>. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3298 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/SConscript27
-rw-r--r--net/disk_cache/disk_cache_perftest.cc26
2 files changed, 41 insertions, 12 deletions
diff --git a/net/SConscript b/net/SConscript
index 74d64b3..b3dd629 100644
--- a/net/SConscript
+++ b/net/SConscript
@@ -282,6 +282,22 @@ net_unittests = env_tests.ChromeTestProgram('net_unittests', unittest_files)
install_targets = net_unittests[:]
+if env['PLATFORM'] in ('posix', 'win32'):
+
+ net_perftests = env_tests.ChromeTestProgram(
+ 'net_perftests',
+ ['disk_cache/disk_cache_test_util.cc',
+ 'disk_cache/disk_cache_perftest.cc',
+ 'base/cookie_monster_perftest.cc',
+ # TODO(sgk): avoid using .cc from base directly
+ '$BASE_DIR/run_all_perftests$OBJSUFFIX',
+ '$BASE_DIR/perftimer$OBJSUFFIX']
+ )
+
+ install_targets.extend([
+ net_perftests
+ ])
+
if env['PLATFORM'] == 'win32':
stress_cache = env_tests.ChromeTestProgram(
'stress_cache',
@@ -295,20 +311,9 @@ if env['PLATFORM'] == 'win32':
'disk_cache/disk_cache_test_util.cc']
)
- net_perftests = env_tests.ChromeTestProgram(
- 'net_perftests',
- ['disk_cache/disk_cache_test_util.cc',
- 'disk_cache/disk_cache_perftest.cc',
- 'base/cookie_monster_perftest.cc',
- # TODO(sgk): avoid using .cc from base directly
- '$BASE_DIR/run_all_perftests$OBJSUFFIX',
- '$BASE_DIR/perftimer$OBJSUFFIX']
- )
-
install_targets.extend([
stress_cache,
crash_cache,
- net_perftests,
])
diff --git a/net/disk_cache/disk_cache_perftest.cc b/net/disk_cache/disk_cache_perftest.cc
index 27f282b..03998df 100644
--- a/net/disk_cache/disk_cache_perftest.cc
+++ b/net/disk_cache/disk_cache_perftest.cc
@@ -2,9 +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_util.h"
#include "base/perftimer.h"
+#if defined(OS_WIN)
#include "base/scoped_handle.h"
+#endif
+#include "base/string_util.h"
#include "base/timer.h"
#include "net/base/net_errors.h"
#include "net/disk_cache/block_files.h"
@@ -21,6 +29,7 @@ extern volatile bool g_cache_tests_error;
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,
@@ -58,6 +67,21 @@ bool EvictFileFromSystemCache(const wchar_t* name) {
}
}
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 {
@@ -178,7 +202,7 @@ TEST_F(DiskCacheTest, Hash) {
PerfTimeLogger timer("Hash disk cache keys");
for (int i = 0; i < 300000; i++) {
std::string key = GenerateKey(true);
- uint32 hash = disk_cache::Hash(key);
+ disk_cache::Hash(key);
}
timer.Done();
}