diff options
author | J. Dekker <jdek@itanimul.li> | 2021-07-20 19:09:22 +0200 |
---|---|---|
committer | J. Dekker <jdek@itanimul.li> | 2021-07-20 19:40:03 +0200 |
commit | 9a727235fd497c22f2370e48dd1443d1376953e7 (patch) | |
tree | aa45dd828846649404001aea6b8e88de8d94bffc /tests/checkasm | |
parent | 4f49fa6abe89e2fca2585cac4c63190315972cf0 (diff) |
lavu/checkasm: add (private) kperf timing for macOS
Signed-off-by: J. Dekker <jdek@itanimul.li>
Diffstat (limited to 'tests/checkasm')
-rw-r--r-- | tests/checkasm/checkasm.c | 14 | ||||
-rw-r--r-- | tests/checkasm/checkasm.h | 7 |
2 files changed, 18 insertions, 3 deletions
diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c index e2e17d2b11..eb9e2cd677 100644 --- a/tests/checkasm/checkasm.c +++ b/tests/checkasm/checkasm.c @@ -638,9 +638,17 @@ static int bench_init_linux(void) } return 0; } -#endif +#elif CONFIG_MACOS_KPERF +static int bench_init_kperf(void) +{ + if (ff_kperf_init()) { + fprintf(stderr, "checkasm must be run as root to use kperf on macOS\n"); + return -1; + } -#if !CONFIG_LINUX_PERF + return 0; +} +#else static int bench_init_ffmpeg(void) { #ifdef AV_READ_TIME @@ -657,6 +665,8 @@ static int bench_init(void) { #if CONFIG_LINUX_PERF int ret = bench_init_linux(); +#elif CONFIG_MACOS_KPERF + int ret = bench_init_kperf(); #else int ret = bench_init_ffmpeg(); #endif diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h index 0593d0edac..b747ed1986 100644 --- a/tests/checkasm/checkasm.h +++ b/tests/checkasm/checkasm.h @@ -31,6 +31,8 @@ #include <sys/ioctl.h> #include <asm/unistd.h> #include <linux/perf_event.h> +#elif CONFIG_MACOS_KPERF +#include "libavutil/macos_kperf.h" #endif #include "libavutil/avstring.h" @@ -225,7 +227,7 @@ typedef struct CheckasmPerf { int iterations; } CheckasmPerf; -#if defined(AV_READ_TIME) || CONFIG_LINUX_PERF +#if defined(AV_READ_TIME) || CONFIG_LINUX_PERF || CONFIG_MACOS_KPERF #if CONFIG_LINUX_PERF #define PERF_START(t) do { \ @@ -236,6 +238,9 @@ typedef struct CheckasmPerf { ioctl(sysfd, PERF_EVENT_IOC_DISABLE, 0); \ read(sysfd, &t, sizeof(t)); \ } while (0) +#elif CONFIG_MACOS_KPERF +#define PERF_START(t) t = ff_kperf_cycles() +#define PERF_STOP(t) t = ff_kperf_cycles() - t #else #define PERF_START(t) t = AV_READ_TIME() #define PERF_STOP(t) t = AV_READ_TIME() - t |