15 "Try up to this many times to guess loops for a benchmark, or skip the "
19 "Loop until timer overhead is at most this fraction of our measurements.");
20static DEFINE_int(overheadLoops, 100000,
"Loops to estimate timer overhead.");
40 for (
int i = 0;
i < FLAGS_overheadLoops;
i++) {
44 overhead /= FLAGS_overheadLoops;
48 double bench_plus_overhead = 0.0;
50 while (bench_plus_overhead < overhead) {
51 if (
round++ == FLAGS_maxCalibrationAttempts) {
52 TestRunner::Log(
"Warning: Cannot estimate loops for %s (%s vs. %s); skipping.",
54 humanize(bench_plus_overhead).c_str(),
56 return std::make_tuple(0,
false);
58 bench_plus_overhead =
time(1);
77 const double numer = overhead / FLAGS_overheadGoal - overhead;
78 const double denom = bench_plus_overhead - overhead;
79 int loops = (
int)
ceil(numer / denom);
81 return std::make_tuple(loops,
true);
96 std::string gpuName)
const override {
98 return std::map<std::string, std::string>();
101 {
"cpu_or_gpu",
"CPU"},
102 {
"cpu_or_gpu_value", cpuName},
109 if (surfaceConfig ==
"nonrendering") {
110 return std::make_unique<NonRenderingBenchmarkTarget>(
benchmark);
115 if (surfaceManager ==
nullptr) {
116 SK_ABORT(
"Unknown --surfaceConfig flag value: %s.", surfaceConfig.c_str());
119 return std::make_unique<RasterBenchmarkTarget>(std::move(surfaceManager),
benchmark);
static void round(SkPoint *p)
static DEFINE_double(overheadGoal, 0.0001, "Loop until timer overhead is at most this fraction of our measurements.")
static DEFINE_int(maxCalibrationAttempts, 3, "Try up to this many times to guess loops for a benchmark, or skip the " "benchmark.")
SkString humanize(double ms)
#define SK_ABORT(message,...)
static std::unique_ptr< BenchmarkTarget > FromConfig(std::string surfaceConfig, Benchmark *benchmark)
static void printGlobalStats()
double time(int loops) const
const char * getUniqueName()
Benchmark::Backend getBackend() const override
std::map< std::string, std::string > getKeyValuePairs(std::string cpuName, std::string gpuName) const override
SurfaceManager::CpuOrGpu isCpuOrGpuBound() const override
NonRenderingBenchmarkTarget(Benchmark *benchmark)
RasterBenchmarkTarget(std::unique_ptr< SurfaceManager > surfaceManager, Benchmark *benchmark)
std::tuple< int, bool > autoTuneLoops() const override
Benchmark::Backend getBackend() const override
static std::unique_ptr< SurfaceManager > FromConfig(std::string config, SurfaceOptions surfaceOptions)
void Log(const char *format,...) SK_PRINTF_LIKE(1
SIN Vec< N, float > ceil(const Vec< N, float > &x)