From: joshualitt Date: Thu, 14 Jan 2016 19:05:22 +0000 (-0800) Subject: Add skeleton for kilobench experiments X-Git-Tag: accepted/tizen/5.0/unified/20181102.025319~184^2~13 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=99f340680959c07a11b8cd654e501f92b41646a3;p=platform%2Fupstream%2FlibSkiaSharp.git Add skeleton for kilobench experiments BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1582903002 Review URL: https://codereview.chromium.org/1582903002 --- diff --git a/gyp/kilobench.gyp b/gyp/kilobench.gyp new file mode 100644 index 0000000..e6578b6 --- /dev/null +++ b/gyp/kilobench.gyp @@ -0,0 +1,36 @@ +# Copyright 2016 Google Inc. +# +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +# GYP file to build performance testbench. +# +{ + 'includes': [ + 'apptype_console.gypi', + ], + 'targets': [ + { + 'target_name': 'kilobench', + 'type': 'executable', + 'include_dirs': [ + '../tools/VisualBench', + '../bench', + '../gm', + ], + 'sources': [ + 'innerNext()) && + (SkCommandLineFlags::ShouldSkip(FLAGS_match, bench->getUniqueName()) || + !bench->isSuitableFor(Benchmark::kGPU_Backend))) { + delete bench; + } + return bench; + } + +private: + static bool ReadPicture(const char* path, SkAutoTUnref* pic) { + // Not strictly necessary, as it will be checked again later, + // but helps to avoid a lot of pointless work if we're going to skip it. + if (SkCommandLineFlags::ShouldSkip(FLAGS_match, path)) { + return false; + } + + SkAutoTDelete stream(SkStream::NewFromFile(path)); + if (stream.get() == nullptr) { + SkDebugf("Could not read %s.\n", path); + return false; + } + + pic->reset(SkPicture::CreateFromStream(stream.get())); + if (pic->get() == nullptr) { + SkDebugf("Could not read %s as an SkPicture.\n", path); + return false; + } + return true; + } + + Benchmark* innerNext() { + // Render skps + while (fCurrentSKP < fSKPs.count()) { + const SkString& path = fSKPs[fCurrentSKP++]; + SkAutoTUnref pic; + if (!ReadPicture(path.c_str(), &pic)) { + continue; + } + + SkString name = SkOSPath::Basename(path.c_str()); + return new VisualSKPBench(name.c_str(), pic.get()); + } + + return nullptr; + } + + SkTArray fSKPs; + int fCurrentSKP; +}; + +} // namespace kilobench + +int kilobench_main() { + kilobench::BenchmarkStream benchStream; + while (Benchmark* b = benchStream.next()) { + SkAutoTDelete bench(b); + // TODO actual stuff + } + return 0; +} + +#if !defined SK_BUILD_FOR_IOS +int main(int argc, char** argv) { + SkCommandLineFlags::Parse(argc, argv); + return kilobench_main(); +} +#endif