Hal Canary | 8751512 | 2019-03-15 14:22:51 -0400 | [diff] [blame] | 1 | // Copyright 2019 Google LLC. |
| 2 | // Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 3 | #include "tools/fiddle/examples.h" |
Hal Canary | 8751512 | 2019-03-15 14:22:51 -0400 | [diff] [blame] | 4 | // HASH=bb761cd858e6d0ca05627262cd22ff5e |
Hal Canary | a7181e7c | 2019-03-18 16:06:34 -0400 | [diff] [blame] | 5 | REG_FIDDLE(Path_updateBoundsCache, 256, 256, true, 0) { |
Hal Canary | 8751512 | 2019-03-15 14:22:51 -0400 | [diff] [blame] | 6 | void draw(SkCanvas* canvas) { |
| 7 | double times[2] = { 0, 0 }; |
| 8 | int N = 100; |
| 9 | for (int i = 0; i < N; ++i) { |
| 10 | SkPath path; |
| 11 | for (int j = 1; j < 100; ++ j) { |
| 12 | path.addCircle(50 + j, 45 + j, 25 + j); |
| 13 | } |
| 14 | if (1 & i) { |
| 15 | path.updateBoundsCache(); |
| 16 | } |
| 17 | double start = SkTime::GetNSecs(); |
| 18 | (void) path.getBounds(); |
| 19 | times[1 & i] += SkTime::GetNSecs() - start; |
| 20 | } |
| 21 | SkDebugf("uncached avg: %g ms\n", times[0] / (double)N); |
| 22 | SkDebugf("cached avg: %g ms\n", times[1] / (double)N); |
| 23 | } |
| 24 | } // END FIDDLE |