From f378090cf5c8ba38861748eb118c6ad2a2fee2b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Tue, 4 Apr 2023 04:46:56 +0200 Subject: [PATCH] Add nanobench (#1967) * Add nanobench * Update xmake.lua * Set headeronly --- packages/n/nanobench/xmake.lua | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 packages/n/nanobench/xmake.lua diff --git a/packages/n/nanobench/xmake.lua b/packages/n/nanobench/xmake.lua new file mode 100644 index 000000000..fb0411df1 --- /dev/null +++ b/packages/n/nanobench/xmake.lua @@ -0,0 +1,28 @@ +package("nanobench") + set_kind("library", {headeronly = true}) + set_homepage("https://nanobench.ankerl.com") + set_description("Simple, fast, accurate single-header microbenchmarking functionality for C++11/14/17/20") + set_license("MIT") + + add_urls("https://github.com/martinus/nanobench/archive/refs/tags/$(version).tar.gz", + "https://github.com/martinus/nanobench.git") + add_versions("v4.3.11", "53a5a913fa695c23546661bf2cd22b299e10a3e994d9ed97daf89b5cada0da70") + + on_install(function (package) + os.cp("src/include/nanobench.h", package:installdir("include")) + end) + + on_test(function (package) + assert(package:check_cxxsnippets({test = [[ + void test() { + double d = 1.0; + ankerl::nanobench::Bench().run("some double ops", [&] { + d += 1.0 / d; + if (d > 5.0) { + d -= 5.0; + } + ankerl::nanobench::doNotOptimizeAway(d); + }); + } + ]]}, {configs = {languages = "c++11"}, defines = "ANKERL_NANOBENCH_IMPLEMENT", includes = "nanobench.h"})) + end)