Add sRGB support to monobench.

We'll now run non-rendering and raster benchmarks,
for simplicity choosing sRGB as the only raster configuration.

$ ninja -C out monobench; and out/monobench "linear_clamp_(3color|pos)\$"
    gradient_linear_clamp_…
    6257  …3color 1x  …pos 1.03x

$ ninja -C out monobench; and out/monobench "linear_clamp_.*[^4][^f]\$"
    gradient_linear_clamp_…
    321  …shallow 1x  …shallow_dither 1x  …3color 1.49x  …hicolor 1.5x  …pos 1.52x

Change-Id: I7282a84c982eb1f11f0ea2dfe39afea66231761c
Reviewed-on: https://skia-review.googlesource.com/16877
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Mike Klein <mtklein@chromium.org>
This commit is contained in:
Mike Klein 2017-05-15 12:19:39 -04:00 committed by Skia Commit-Bot
parent cbd0f3b4e3
commit 0dc6dd0a3f

View File

@ -8,6 +8,7 @@
#include "Benchmark.h"
#include "OverwriteLine.h"
#include "SkGraphics.h"
#include "SkSurface.h"
#include "SkTaskGroup.h"
#include <algorithm>
#include <chrono>
@ -48,7 +49,8 @@ int main(int argc, char** argv) {
std::string name = bench->getName();
if (std::regex_search(name, pattern) &&
bench->isSuitableFor(Benchmark::kNonRendering_Backend)) {
(bench->isSuitableFor(Benchmark::kNonRendering_Backend) ||
bench->isSuitableFor(Benchmark:: kRaster_Backend))) {
bench->delayedSetup();
benches.emplace_back(Bench{std::move(bench), name,
ns{std::numeric_limits<double>::infinity()}});
@ -96,12 +98,22 @@ int main(int argc, char** argv) {
while (samples < limit) {
std::random_shuffle(benches.begin(), benches.end());
for (auto& bench : benches) {
sk_sp<SkSurface> dst;
SkCanvas* canvas = nullptr;
if (!bench.b->isSuitableFor(Benchmark::kNonRendering_Backend)) {
dst = SkSurface::MakeRaster(SkImageInfo::MakeS32(bench.b->getSize().x(),
bench.b->getSize().y(),
kPremul_SkAlphaType));
canvas = dst->getCanvas();
bench.b->perCanvasPreDraw(canvas);
}
for (int loops = 1; loops < 1000000000;) {
bench.b->preDraw(nullptr);
bench.b->preDraw(canvas);
auto start = clock::now();
bench.b->draw(loops, nullptr);
bench.b->draw(loops, canvas);
ns elapsed = clock::now() - start;
bench.b->postDraw(nullptr);
bench.b->postDraw(canvas);
if (elapsed < std::chrono::milliseconds{10}) {
loops *= 2;
@ -131,6 +143,9 @@ int main(int argc, char** argv) {
}
break;
}
if (canvas) {
bench.b->perCanvasPostDraw(canvas);
}
}
}