OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 // A benchmark designed to isolate the constant overheads of picture recording. | 8 // A benchmark designed to isolate the constant overheads of picture recording. |
9 // We record an empty picture and a picture with one draw op to force memory all
ocation. | 9 // We record an empty picture and a picture with one draw op to force memory all
ocation. |
10 | 10 |
11 #include "Benchmark.h" | 11 #include "Benchmark.h" |
12 #include "SkCanvas.h" | 12 #include "SkCanvas.h" |
13 #include "SkLiteDL.h" | 13 #include "SkLiteDL.h" |
14 #include "SkLiteRecorder.h" | 14 #include "SkLiteRecorder.h" |
15 #include "SkPictureRecorder.h" | 15 #include "SkPictureRecorder.h" |
16 | 16 |
17 template <int kDraws, bool kLite> | 17 template <int kDraws, bool kLite> |
18 struct PictureOverheadBench : public Benchmark { | 18 struct PictureOverheadBench : public Benchmark { |
19 PictureOverheadBench() { | 19 PictureOverheadBench() { |
20 fName.appendf("picture_overhead_%d%s\n", kDraws, kLite ? "_lite" : ""); | 20 fName.appendf("picture_overhead_%d%s", kDraws, kLite ? "_lite" : ""); |
21 } | 21 } |
22 const char* onGetName() override { return fName.c_str(); } | 22 const char* onGetName() override { return fName.c_str(); } |
23 bool isSuitableFor(Backend backend) override { return backend == kNonRenderi
ng_Backend; } | 23 bool isSuitableFor(Backend backend) override { return backend == kNonRenderi
ng_Backend; } |
24 | 24 |
25 void onDraw(int loops, SkCanvas*) override { | 25 void onDraw(int loops, SkCanvas*) override { |
26 SkLiteRecorder lite; | 26 SkLiteRecorder lite; |
27 SkPictureRecorder rec; | 27 SkPictureRecorder rec; |
28 for (int i = 0; i < loops; i++) { | 28 for (int i = 0; i < loops; i++) { |
29 SkRect bounds{0,0, 2000,3000}; | 29 SkRect bounds{0,0, 2000,3000}; |
30 | 30 |
(...skipping 22 matching lines...) Expand all Loading... |
53 }; | 53 }; |
54 | 54 |
55 DEF_BENCH(return (new PictureOverheadBench<0, false>);) | 55 DEF_BENCH(return (new PictureOverheadBench<0, false>);) |
56 DEF_BENCH(return (new PictureOverheadBench<1, false>);) | 56 DEF_BENCH(return (new PictureOverheadBench<1, false>);) |
57 DEF_BENCH(return (new PictureOverheadBench<2, false>);) | 57 DEF_BENCH(return (new PictureOverheadBench<2, false>);) |
58 DEF_BENCH(return (new PictureOverheadBench<10,false>);) | 58 DEF_BENCH(return (new PictureOverheadBench<10,false>);) |
59 DEF_BENCH(return (new PictureOverheadBench<0, true>);) | 59 DEF_BENCH(return (new PictureOverheadBench<0, true>);) |
60 DEF_BENCH(return (new PictureOverheadBench<1, true>);) | 60 DEF_BENCH(return (new PictureOverheadBench<1, true>);) |
61 DEF_BENCH(return (new PictureOverheadBench<2, true>);) | 61 DEF_BENCH(return (new PictureOverheadBench<2, true>);) |
62 DEF_BENCH(return (new PictureOverheadBench<10, true>);) | 62 DEF_BENCH(return (new PictureOverheadBench<10, true>);) |
OLD | NEW |