#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include <limits>
#include <memory>
#include <string>
#include "base/barrier_closure.h"
#include "base/files/file_enumerator.h"
#include "base/files/file_path.h"
#include "base/functional/bind.h"
#include "base/hash/hash.h"
#include "base/memory/raw_ptr.h"
#include "base/process/process_metrics.h"
#include "base/rand_util.h"
#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/test/scoped_run_loop_timeout.h"
#include "base/test/test_file_util.h"
#include "base/test/test_timeouts.h"
#include "base/threading/thread.h"
#include "base/time/time.h"
#include "base/timer/elapsed_timer.h"
#include "build/build_config.h"
#include "net/base/cache_type.h"
#include "net/base/completion_repeating_callback.h"
#include "net/base/io_buffer.h"
#include "net/base/net_errors.h"
#include "net/base/test_completion_callback.h"
#include "net/disk_cache/backend_cleanup_tracker.h"
#include "net/disk_cache/blockfile/backend_impl.h"
#include "net/disk_cache/blockfile/block_files.h"
#include "net/disk_cache/disk_cache.h"
#include "net/disk_cache/disk_cache_test_base.h"
#include "net/disk_cache/disk_cache_test_util.h"
#include "net/disk_cache/simple/simple_backend_impl.h"
#include "net/disk_cache/simple/simple_index.h"
#include "net/disk_cache/simple/simple_index_file.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/perf/perf_result_reporter.h"
#include "testing/platform_test.h"
Time;
namespace {
const size_t kNumEntries = …;
const int kHeadersSize = …;
const int kBodySize = …;
const int kChunkSize = …;
const int kMaxParallelOperations = …;
static constexpr char kMetricPrefixDiskCache[] = …;
static constexpr char kMetricPrefixSimpleIndex[] = …;
static constexpr char kMetricCacheEntriesWriteTimeMs[] = …;
static constexpr char kMetricCacheHeadersReadTimeColdMs[] = …;
static constexpr char kMetricCacheHeadersReadTimeWarmMs[] = …;
static constexpr char kMetricCacheEntriesReadTimeColdMs[] = …;
static constexpr char kMetricCacheEntriesReadTimeWarmMs[] = …;
static constexpr char kMetricCacheKeysHashTimeMs[] = …;
static constexpr char kMetricFillBlocksTimeMs[] = …;
static constexpr char kMetricCreateDeleteBlocksTimeMs[] = …;
static constexpr char kMetricSimpleCacheInitTotalTimeMs[] = …;
static constexpr char kMetricSimpleCacheInitPerEntryTimeUs[] = …;
static constexpr char kMetricAverageEvictionTimeMs[] = …;
perf_test::PerfResultReporter SetUpDiskCacheReporter(const std::string& story) { … }
perf_test::PerfResultReporter SetUpSimpleIndexReporter(
const std::string& story) { … }
void MaybeIncreaseFdLimitTo(unsigned int max_descriptors) { … }
struct TestEntry { … };
enum class WhatToRead { … };
class DiskCachePerfTest : public DiskCacheTestWithCache { … };
class WriteHandler { … };
void WriteHandler::Run() { … }
void WriteHandler::CreateNextEntry() { … }
void WriteHandler::CreateCallback(int data_len,
disk_cache::EntryResult result) { … }
void WriteHandler::WriteDataCallback(disk_cache::Entry* entry,
int next_offset,
int data_len,
int expected_result,
int result) { … }
bool WriteHandler::CheckForErrorAndCancel(int result) { … }
class ReadHandler { … };
void ReadHandler::Run() { … }
void ReadHandler::OpenNextEntry(int parallel_operation_index) { … }
void ReadHandler::OpenCallback(int parallel_operation_index,
int data_len,
disk_cache::EntryResult result) { … }
void ReadHandler::ReadDataCallback(int parallel_operation_index,
disk_cache::Entry* entry,
int next_offset,
int data_len,
int expected_result,
int result) { … }
bool ReadHandler::CheckForErrorAndCancel(int result) { … }
bool DiskCachePerfTest::TimeWrites(const std::string& story) { … }
bool DiskCachePerfTest::TimeReads(WhatToRead what_to_read,
const std::string& metric,
const std::string& story) { … }
TEST_F(DiskCachePerfTest, BlockfileHashes) { … }
void DiskCachePerfTest::ResetAndEvictSystemDiskCache() { … }
void DiskCachePerfTest::CacheBackendPerformance(const std::string& story) { … }
#if BUILDFLAG(IS_FUCHSIA)
#define MAYBE_CacheBackendPerformance …
#else
#define MAYBE_CacheBackendPerformance …
#endif
TEST_F(DiskCachePerfTest, MAYBE_CacheBackendPerformance) { … }
#if BUILDFLAG(IS_FUCHSIA)
#define MAYBE_SimpleCacheBackendPerformance …
#else
#define MAYBE_SimpleCacheBackendPerformance …
#endif
TEST_F(DiskCachePerfTest, MAYBE_SimpleCacheBackendPerformance) { … }
TEST_F(DiskCachePerfTest, BlockFilesPerformance) { … }
void VerifyRvAndCallClosure(base::RepeatingClosure* c, int expect_rv, int rv) { … }
TEST_F(DiskCachePerfTest, SimpleCacheInitialReadPortion) { … }
#if BUILDFLAG(IS_FUCHSIA)
#define MAYBE_EvictionPerformance …
#else
#define MAYBE_EvictionPerformance …
#endif
TEST(SimpleIndexPerfTest, MAYBE_EvictionPerformance) { … }
}