2 * Copyright 2022 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
7 * This is an experimental (and probably temporary) solution that allows
8 * to compare performance SkVM blitters vs RasterPipeline blitters.
9 * In addition to measuring performance (which is questionable) it also produces
10 * other counts (pixels, scanlines) and more detailed traces that
11 * can explain the current results (SkVM is slower) and help improve it.
12 * The entire code is hidden under build flag skia_compare_vm_vs_rp=true
13 * and will not appear at all without it.
15 #ifndef SkCycles_DEFINED
16 #define SkCycles_DEFINED
18 #include <x86intrin.h>
21 static uint64_t Now() {
22 #ifndef SKIA_COMPARE_VM_VS_RP
26 #elif defined(SK_BUILD_FOR_WIN)
30 #elif defined(SK_BUILD_FOR_IOS)
34 #elif defined(SK_BUILD_FOR_ANDROID)
38 #elif defined(SK_CPU_X86)
41 return __rdtscp(&aux);
43 #elif defined(SK_CPU_ARM64)
46 asm volatile("mrs %0, cntvct_el0" : "=r"(cycles));
56 #endif // SkCycles_DEFINED