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

Unified Diff: net/disk_cache/disk_cache_perftest.cc

Issue 6080: This makes net_perftests build and run on Linux. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 12 years, 3 months 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 | « net/SConscript ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/disk_cache/disk_cache_perftest.cc
===================================================================
--- net/disk_cache/disk_cache_perftest.cc (revision 2786)
+++ net/disk_cache/disk_cache_perftest.cc (working copy)
@@ -2,9 +2,18 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <fcntl.h>
+#include <unistd.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 +30,7 @@
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 +68,21 @@
}
}
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 +203,7 @@
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();
}
« no previous file with comments | « net/SConscript ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698