chromium/components/visitedlink/test/visitedlink_perftest.cc

// Copyright 2010 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <algorithm>
#include <string>
#include <vector>

#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/strings/stringprintf.h"
#include "base/test/scoped_run_loop_timeout.h"
#include "base/test/test_file_util.h"
#include "base/timer/elapsed_timer.h"
#include "build/build_config.h"
#include "components/visitedlink/browser/visitedlink_writer.h"
#include "content/public/test/browser_task_environment.h"
#include "content/public/test/test_utils.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/perf/perf_result_reporter.h"
#include "url/gurl.h"


namespace visitedlink {

namespace {

static constexpr char kMetricAddAndQueryMs[] =;
static constexpr char kMetricTableInitMs[] =;
static constexpr char kMetricLinkInitMs[] =;
static constexpr char kMetricDatabaseFlushMs[] =;
static constexpr char kMetricColdLoadTimeMs[] =;
static constexpr char kMetricHotLoadTimeMs[] =;
static constexpr char kMetricAddURLTimeMs[] =;
static constexpr char kMetricAddURLsTimeMs[] =;

perf_test::PerfResultReporter SetUpReporter(const std::string& metric_suffix) {}

// Designed like base/test/perf_time_logger but uses testing/perf instead of
// base/test/perf* to report timings.
class TimeLogger {};

TimeLogger::TimeLogger(std::string metric_suffix)
    :{}

TimeLogger::~TimeLogger() {}

void TimeLogger::Done() {}

// how we generate URLs, note that the two strings should be the same length
const int kAddCount =;
const int kLoadTestInitialCount =;
const char kAddedPrefix[] =;
const char kUnaddedPrefix[] =;

// Returns a URL with the given prefix and index
GURL TestURL(const char* prefix, int i) {}

// We have no readers, so all methods on this listener are a no-ops.
class DummyVisitedLinkEventListener : public VisitedLinkWriter::Listener {};

// this checks IsVisited for the URLs starting with the given prefix and
// within the given range
void CheckVisited(VisitedLinkWriter& writer,
                  const char* prefix,
                  int begin,
                  int end) {}

// Fills that writer's table with URLs starting with the given prefix and
// within the given range
void FillTable(VisitedLinkWriter& writer,
               const char* prefix,
               int begin,
               int end,
               int batch_size = 1) {}

class VisitedLinkPerfTest : public testing::Test {};

} // namespace

// This test tests adding many things to a database, and how long it takes
// to query the database with different numbers of things in it. The time
// is the total time to do all the operations, and as such, it is only
// useful for a regression test. If there is a regression, it might be
// useful to make another set of tests to test these things in isolation.
TEST_F(VisitedLinkPerfTest, TestAddAndQuery) {}

// Tests how long it takes to write and read a large database to and from disk.
// TODO(crbug.com/40719465): Fix flakiness on macOS and Android.
#if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_ANDROID)
#define MAYBE_TestBigTable
#else
#define MAYBE_TestBigTable
#endif
TEST_F(VisitedLinkPerfTest, MAYBE_TestBigTable) {}

}  // namespace visitedlink