From 042050ef67a0d320469a6f8ca74bd8684ec4c409 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Fri, 29 Jan 2016 11:47:40 +0100 Subject: Added Google Benchmark library (nw) Included sample benchmark for eminline for native and noasm Made GoogleTest compile only if tests are compiled --- benchmarks/eminline_native.cpp | 15 +++++++++++++++ benchmarks/eminline_noasm.cpp | 24 ++++++++++++++++++++++++ benchmarks/main.cpp | 6 ++++++ 3 files changed, 45 insertions(+) create mode 100644 benchmarks/eminline_native.cpp create mode 100644 benchmarks/eminline_noasm.cpp create mode 100644 benchmarks/main.cpp (limited to 'benchmarks') diff --git a/benchmarks/eminline_native.cpp b/benchmarks/eminline_native.cpp new file mode 100644 index 00000000000..07bfa02bb1d --- /dev/null +++ b/benchmarks/eminline_native.cpp @@ -0,0 +1,15 @@ +// license:BSD-3-Clause +// copyright-holders:Miodrag Milanovic + +#include "benchmark/benchmark_api.h" +#include "osdcomm.h" +#include "eminline.h" +static void BM_count_leading_zeros_native(benchmark::State& state) { + UINT32 cnt = 0x332533; + while (state.KeepRunning()) { + (void)count_leading_zeros(cnt); + cnt++; + } +} +// Register the function as a benchmark +BENCHMARK(BM_count_leading_zeros_native); diff --git a/benchmarks/eminline_noasm.cpp b/benchmarks/eminline_noasm.cpp new file mode 100644 index 00000000000..43c9e36b020 --- /dev/null +++ b/benchmarks/eminline_noasm.cpp @@ -0,0 +1,24 @@ +// license:BSD-3-Clause +// copyright-holders:Miodrag Milanovic + +#include "benchmark/benchmark_api.h" +#include +#include "osdcore.h" +#include "osdcomm.h" +#define MAME_NOASM 1 +osd_ticks_t osd_ticks(void) +{ + // use the standard library clock function + return clock(); +} +#include "eminline.h" + +static void BM_count_leading_zeros_noasm(benchmark::State& state) { + UINT32 cnt = 0x332533; + while (state.KeepRunning()) { + (void)count_leading_zeros(cnt); + cnt++; + } +} +// Register the function as a benchmark +BENCHMARK(BM_count_leading_zeros_noasm); diff --git a/benchmarks/main.cpp b/benchmarks/main.cpp new file mode 100644 index 00000000000..c859b918976 --- /dev/null +++ b/benchmarks/main.cpp @@ -0,0 +1,6 @@ +// license:BSD-3-Clause +// copyright-holders:Miodrag Milanovic + +#include "benchmark/benchmark_api.h" + +BENCHMARK_MAIN(); \ No newline at end of file -- cgit v1.2.3-70-g09d2