qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: qemu-devel@nongnu.org
Cc: amonakov@ispras.ru, mmromanov@ispras.ru
Subject: [PATCH v5 10/10] tests/bench: Add bufferiszero-bench
Date: Fri, 16 Feb 2024 14:39:18 -1000	[thread overview]
Message-ID: <20240217003918.52229-11-richard.henderson@linaro.org> (raw)
In-Reply-To: <20240217003918.52229-1-richard.henderson@linaro.org>

Benchmark each acceleration function vs an aligned buffer of zeros.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 tests/bench/bufferiszero-bench.c | 42 ++++++++++++++++++++++++++++++++
 tests/bench/meson.build          |  4 ++-
 2 files changed, 45 insertions(+), 1 deletion(-)
 create mode 100644 tests/bench/bufferiszero-bench.c

diff --git a/tests/bench/bufferiszero-bench.c b/tests/bench/bufferiszero-bench.c
new file mode 100644
index 0000000000..1fa2eb6973
--- /dev/null
+++ b/tests/bench/bufferiszero-bench.c
@@ -0,0 +1,42 @@
+/*
+ * QEMU buffer_is_zero speed benchmark
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or
+ * (at your option) any later version.  See the COPYING file in the
+ * top-level directory.
+ */
+#include "qemu/osdep.h"
+#include "qemu/cutils.h"
+#include "qemu/units.h"
+
+static void test(const void *opaque)
+{
+    size_t len = 64 * KiB;
+    void *buf = g_malloc0(len);
+    int accel_index = 0;
+
+    do {
+        double total = 0.0;
+
+        g_test_timer_start();
+        do {
+            buffer_is_zero_ge256(buf, len);
+            total += len;
+        } while (g_test_timer_elapsed() < 5.0);
+
+        total /= MiB;
+        g_test_message("buffer_is_zero #%d: %.2f MB/sec",
+                       accel_index, total / g_test_timer_last());
+
+        accel_index++;
+    } while (test_buffer_is_zero_next_accel());
+
+    g_free(buf);
+}
+
+int main(int argc, char **argv)
+{
+    g_test_init(&argc, &argv, NULL);
+    g_test_add_data_func("/cutils/bufferiszero/speed", NULL, test);
+    return g_test_run();
+}
diff --git a/tests/bench/meson.build b/tests/bench/meson.build
index 7e76338a52..70d45ff400 100644
--- a/tests/bench/meson.build
+++ b/tests/bench/meson.build
@@ -17,7 +17,9 @@ executable('atomic64-bench',
            dependencies: [qemuutil],
            build_by_default: false)
 
-benchs = {}
+benchs = {
+    'bufferiszero-bench': [],
+}
 
 if have_block
   benchs += {
-- 
2.34.1



  parent reply	other threads:[~2024-02-17  0:40 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-17  0:39 [PATCH v5 00/10] Optimize buffer_is_zero Richard Henderson
2024-02-17  0:39 ` [PATCH v5 01/10] util/bufferiszero: Remove SSE4.1 variant Richard Henderson
2024-02-17  0:39 ` [PATCH v5 02/10] util/bufferiszero: Remove AVX512 variant Richard Henderson
2024-02-17  0:39 ` [PATCH v5 03/10] util/bufferiszero: Reorganize for early test for acceleration Richard Henderson
2024-02-17  0:39 ` [PATCH v5 04/10] util/bufferiszero: Remove useless prefetches Richard Henderson
2024-02-17  0:39 ` [PATCH v5 05/10] util/bufferiszero: Optimize SSE2 and AVX2 variants Richard Henderson
2024-02-17  0:39 ` [PATCH v5 06/10] util/bufferiszero: Improve scalar variant Richard Henderson
2024-02-17 12:13   ` Alexander Monakov
2024-02-17 19:18     ` Richard Henderson
2024-02-17  0:39 ` [PATCH v5 07/10] util/bufferiszero: Introduce biz_accel_fn typedef Richard Henderson
2024-02-17  0:39 ` [PATCH v5 08/10] util/bufferiszero: Simplify test_buffer_is_zero_next_accel Richard Henderson
2024-02-17  0:39 ` [PATCH v5 09/10] util/bufferiszero: Add simd acceleration for aarch64 Richard Henderson
2024-02-17 11:33   ` Alexander Monakov
2024-02-17 19:19     ` Richard Henderson
2024-02-17  0:39 ` Richard Henderson [this message]
2024-02-17  9:49   ` [PATCH v5 10/10] tests/bench: Add bufferiszero-bench Alexander Monakov
2024-02-17 19:21     ` Richard Henderson
2024-02-19 10:02       ` Daniel P. Berrangé

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240217003918.52229-11-richard.henderson@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=amonakov@ispras.ru \
    --cc=mmromanov@ispras.ru \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).