]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
chore(dnsdist): Add Lua OT function registration benchmark
authorPieter Lexis <pieter.lexis@powerdns.com>
Mon, 30 Mar 2026 10:07:04 +0000 (12:07 +0200)
committerPieter Lexis <pieter.lexis@powerdns.com>
Mon, 1 Jun 2026 10:51:43 +0000 (12:51 +0200)
pdns/dnsdistdist/bench-dnsdist-lua-bindings-opentelemetry_cc.cc [new file with mode: 0644]
pdns/dnsdistdist/meson.build

diff --git a/pdns/dnsdistdist/bench-dnsdist-lua-bindings-opentelemetry_cc.cc b/pdns/dnsdistdist/bench-dnsdist-lua-bindings-opentelemetry_cc.cc
new file mode 100644 (file)
index 0000000..827c0c9
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * This file is part of PowerDNS or dnsdist.
+ * Copyright -- PowerDNS.COM B.V. and its contributors
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * In addition, for the avoidance of any doubt, permission is granted to
+ * link this program with OpenSSL and to (re)distribute the binaries
+ * produced as the result of such linking.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+#include <memory>
+#define CATCH_CONFIG_NO_MAIN
+#include <catch2/catch_test_macros.hpp>
+#include <catch2/benchmark/catch_benchmark.hpp>
+
+#include "dnsdist-opentelemetry.hh"
+#include "dnsdist-lua-bindings-opentelemetry.hh"
+
+TEST_CASE("lua-bindings-opentelemetry")
+{
+  auto tracer = pdns::trace::dnsdist::Tracer::getTracer();
+  size_t testnum = 0;
+
+  BENCHMARK("withTracer")
+  {
+    return pdns::trace::dnsdist::runWithLuaTracing(tracer, [&testnum]() {
+      return testnum++;
+    });
+  };
+
+  testnum = 0;
+  tracer = nullptr;
+  BENCHMARK("withoutTracer")
+  {
+    return pdns::trace::dnsdist::runWithLuaTracing(tracer, [&testnum]() {
+      return testnum++;
+    });
+  };
+}
index 0db317a45e6762d50dbee8ce356699268eccbef4..42284f770f90f9cdeecce3386dcbb594197c34c3 100644 (file)
@@ -606,6 +606,7 @@ benchmark_sources = files(
   src_dir / 'bench-dnsdist-action-rcode.cc',
   src_dir / 'bench-dnsdist-cache.cc',
   src_dir / 'bench-dnsdist-dnsparser_cc.cc',
+  src_dir / 'bench-dnsdist-lua-bindings-opentelemetry_cc.cc',
   src_dir / 'bench-dnsdist-opentelemetry_cc.cc',
   src_dir / 'bench-dnsdist-rings_cc.cc',
   src_dir / 'bench-misc_hh.cc',