aboutsummaryrefslogtreecommitdiffhomepage
path: root/bench/TextBlobBench.cpp
diff options
context:
space:
mode:
authorGravatar kkinnunen <kkinnunen@nvidia.com>2015-05-21 06:15:28 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-05-21 06:15:28 -0700
commitb4a797f3aa8c10387f01cf51a65dd1a8aa5eec9d (patch)
tree988c6fac18d299111d00a4404666899011745db0 /bench/TextBlobBench.cpp
parent070e01056acdd9980619e71e2da390efb94e912e (diff)
Move font loading in gm tests and benches out of constructors
Constructing the gm tests and benches causes many calls to font loads. This is visible as profiling samples in fontconfig and freetype on Linux for all profiling runs of nanobench. This complicates analysis of test-cases that are suspected of being slow due to font-related issues. Move the font loading to GM::onOnceBeforeDraw and Benchmark::onPreDraw. This way the code is not executed if the testcase does not match the nanobench --match filter. This way the samples in font-related code are more easy to identify as legitimate occurances caused by the testcase. This should not cause differences in timings, because: * Benchmark::preDraw / onPreDraw is defined to be run outside the timer * GM::runAsBench is not enabled for any of the modified testcases. Also nanobench untimed warmup round should run the onOnceBeforeDraw. (and there are other GM::runAsBench gms already doing loading in onOnceBeforeDraw). Changes the behavior: In TextBench: Before, the test would report two different gms with the same name if the color emoji font was not loaded successfully. After, the test always reports all tests as individual names. Generally: The errors from loading fonts now print inbetween each testcase, as opposed to printing during construction phase. Sample output: ( 143/145 MB 1872) 14.7ms 8888 gm quadclosepathResource /fonts/Funkster.ttf not a valid font. ( 160/160 MB 1831) 575µs 8888 gm surfacenewResource /fonts/Funkster.ttf not a valid font. ( 163/165 MB 1816) 12.5ms 8888 gm linepathResource /fonts/Funkster.ttf not a valid font. ( 263/411 MB 1493) 118ms 8888 gm typefacestyles_kerningResource /fonts/Funkster.ttf not a valid font. ( 374/411 MB 1231) 7.16ms 565 gm getpostextpathResource /fonts/Funkster.ttf not a valid font. ( 323/411 MB 1179) 4.92ms 565 gm stringartResource /fonts/Funkster.ttf not a valid font. ( 347/493 MB 917) 191ms 565 gm patch_gridResource /fonts/Funkster.ttf not a valid font. ( 375/493 MB 857) 23.9ms gpu gm clipdrawdrawCannot render path (0) ( 393/493 MB 706) 2.91ms unit test ParsePath------ png error IEND: CRC error ( 394/493 MB 584) 166ms gpu gm hairmodesResource /fonts/Funkster.ttf not a valid font. Resource /fonts/Funkster.ttf not a valid font. Resource /fonts/Funkster.ttf not a valid font. ... Review URL: https://codereview.chromium.org/1144023002
Diffstat (limited to 'bench/TextBlobBench.cpp')
-rw-r--r--bench/TextBlobBench.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/bench/TextBlobBench.cpp b/bench/TextBlobBench.cpp
index 1f4b2b7120..ae71a1e41a 100644
--- a/bench/TextBlobBench.cpp
+++ b/bench/TextBlobBench.cpp
@@ -25,7 +25,12 @@
class TextBlobBench : public Benchmark {
public:
TextBlobBench()
- : fTypeface(sk_tool_utils::create_portable_typeface("Times", SkTypeface::kNormal)) {
+ : fTypeface(NULL) {
+ }
+
+protected:
+ void onPreDraw() override {
+ fTypeface.reset(sk_tool_utils::create_portable_typeface("Times", SkTypeface::kNormal));
// make textblob
SkPaint paint;
paint.setTypeface(fTypeface);
@@ -45,7 +50,6 @@ public:
fBlob.reset(builder.build());
}
-protected:
const char* onGetName() {
return "TextBlobBench";
}