chromium/skia/ext/image_operations_bench.cc

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

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/351564777): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

// This small program is used to measure the performance of the various
// resize algorithms offered by the ImageOperations::Resize function.
// It will generate an empty source bitmap, and rescale it to specified
// dimensions. It will repeat this operation multiple time to get more accurate
// average throughput. Because it uses elapsed time to do its math, it is only
// accurate on an idle system (but that approach was deemed more accurate
// than the use of the times() call.
// To present a single number in MB/s, it calculates the 'speed' by taking
// source surface + destination surface and dividing by the elapsed time.
// This number is somewhat reasonable way to measure this, given our current
// implementation which somewhat scales this way.

#include <stddef.h>
#include <stdint.h>
#include <stdio.h>

#include <string_view>

#include "base/command_line.h"
#include "base/format_macros.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "skia/ext/image_operations.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkRect.h"

namespace {

struct StringMethodPair {};
#define ADD_METHOD(x)
const StringMethodPair resize_methods[] =;

// converts a string into one of the image operation method to resize.
// Returns true on success, false otherwise.
bool StringToMethod(const std::string& arg,
                    skia::ImageOperations::ResizeMethod* method) {}

const char* MethodToString(skia::ImageOperations::ResizeMethod method) {}

// Prints all supported resize methods
void PrintMethods() {}

// Returns the number of bytes that the bitmap has. This number is different
// from what SkBitmap::getSize() returns since it does not take into account
// the stride. The difference between the stride and the width can be large
// because of the alignment constraints on bitmaps created for SRB scaling
// (32 pixels) as seen on GTV platforms. Using this metric instead of the
// getSize seemed to be a more accurate representation of the work done (even
// though in terms of memory bandwidth that might be similar because of the
// cache line size).
int GetBitmapSize(const SkBitmap* bitmap) {}

// Simple class to represent dimensions of a bitmap (width, height).
class Dimensions {};

// main class used for the benchmarking.
class Benchmark {};

// static
const int Benchmark::kDefaultNumberIterations =;
const skia::ImageOperations::ResizeMethod Benchmark::kDefaultResizeMethod =;

// argument management
void Benchmark::Usage() {}

bool Benchmark::ParseArgs(const base::CommandLine* command_line) {}

// actual benchmark.
bool Benchmark::Run() const {}

// A small class to automatically call Reset on the global command line to
// avoid nasty valgrind complaints for the leak of the global command line.
class CommandLineAutoReset {};

}  // namespace

int main(int argc, char** argv) {}