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