|
Pablo Greco |
e6a3ae |
From f12961093254d12f8f7ccfd8feca7a32f558e12d Mon Sep 17 00:00:00 2001
|
|
Pablo Greco |
e6a3ae |
From: "Daniel P. Berrange" <berrange@redhat.com>
|
|
Pablo Greco |
e6a3ae |
Date: Wed, 24 Apr 2019 09:56:35 +0100
|
|
Pablo Greco |
e6a3ae |
Subject: [PATCH 1/9] tests/crypto: Use the IEC binary prefix definitions
|
|
Pablo Greco |
e6a3ae |
MIME-Version: 1.0
|
|
Pablo Greco |
e6a3ae |
Content-Type: text/plain; charset=UTF-8
|
|
Pablo Greco |
e6a3ae |
Content-Transfer-Encoding: 8bit
|
|
Pablo Greco |
e6a3ae |
|
|
Pablo Greco |
e6a3ae |
RH-Author: Daniel P. Berrange <berrange@redhat.com>
|
|
Pablo Greco |
e6a3ae |
Message-id: <20190424095643.796-2-berrange@redhat.com>
|
|
Pablo Greco |
e6a3ae |
Patchwork-id: 85878
|
|
Pablo Greco |
e6a3ae |
O-Subject: [RHEL-8.1.0 qemu-kvm PATCH 1/9] tests/crypto: Use the IEC binary prefix definitions
|
|
Pablo Greco |
e6a3ae |
Bugzilla: 1680231
|
|
Pablo Greco |
e6a3ae |
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
|
|
Pablo Greco |
e6a3ae |
RH-Acked-by: John Snow <jsnow@redhat.com>
|
|
Pablo Greco |
e6a3ae |
RH-Acked-by: Eric Blake <eblake@redhat.com>
|
|
Pablo Greco |
e6a3ae |
|
|
Pablo Greco |
e6a3ae |
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
|
|
Pablo Greco |
e6a3ae |
|
|
Pablo Greco |
e6a3ae |
It eases code review, unit is explicit.
|
|
Pablo Greco |
e6a3ae |
|
|
Pablo Greco |
e6a3ae |
Patch generated using:
|
|
Pablo Greco |
e6a3ae |
|
|
Pablo Greco |
e6a3ae |
$ git grep -n '[<>][<>]= ?[1-5]0'
|
|
Pablo Greco |
e6a3ae |
|
|
Pablo Greco |
e6a3ae |
and modified manually.
|
|
Pablo Greco |
e6a3ae |
|
|
Pablo Greco |
e6a3ae |
Suggested-by: Eric Blake <eblake@redhat.com>
|
|
Pablo Greco |
e6a3ae |
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
|
|
Pablo Greco |
e6a3ae |
Message-Id: <20180625124238.25339-45-f4bug@amsat.org>
|
|
Pablo Greco |
e6a3ae |
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
Pablo Greco |
e6a3ae |
(cherry picked from commit 68dbb6d05db59fe39af0c192005490576d9f5b7c)
|
|
Pablo Greco |
e6a3ae |
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
|
Pablo Greco |
e6a3ae |
---
|
|
Pablo Greco |
e6a3ae |
tests/benchmark-crypto-cipher.c | 6 +++---
|
|
Pablo Greco |
e6a3ae |
tests/benchmark-crypto-hash.c | 5 +++--
|
|
Pablo Greco |
e6a3ae |
tests/benchmark-crypto-hmac.c | 6 +++---
|
|
Pablo Greco |
e6a3ae |
3 files changed, 9 insertions(+), 8 deletions(-)
|
|
Pablo Greco |
e6a3ae |
|
|
Pablo Greco |
e6a3ae |
diff --git a/tests/benchmark-crypto-cipher.c b/tests/benchmark-crypto-cipher.c
|
|
Pablo Greco |
e6a3ae |
index cf98443..f5a0d0b 100644
|
|
Pablo Greco |
e6a3ae |
--- a/tests/benchmark-crypto-cipher.c
|
|
Pablo Greco |
e6a3ae |
+++ b/tests/benchmark-crypto-cipher.c
|
|
Pablo Greco |
e6a3ae |
@@ -11,6 +11,7 @@
|
|
Pablo Greco |
e6a3ae |
* top-level directory.
|
|
Pablo Greco |
e6a3ae |
*/
|
|
Pablo Greco |
e6a3ae |
#include "qemu/osdep.h"
|
|
Pablo Greco |
e6a3ae |
+#include "qemu/units.h"
|
|
Pablo Greco |
e6a3ae |
#include "crypto/init.h"
|
|
Pablo Greco |
e6a3ae |
#include "crypto/cipher.h"
|
|
Pablo Greco |
e6a3ae |
|
|
Pablo Greco |
e6a3ae |
@@ -56,8 +57,7 @@ static void test_cipher_speed(const void *opaque)
|
|
Pablo Greco |
e6a3ae |
total += chunk_size;
|
|
Pablo Greco |
e6a3ae |
} while (g_test_timer_elapsed() < 5.0);
|
|
Pablo Greco |
e6a3ae |
|
|
Pablo Greco |
e6a3ae |
- total /= 1024 * 1024; /* to MB */
|
|
Pablo Greco |
e6a3ae |
-
|
|
Pablo Greco |
e6a3ae |
+ total /= MiB;
|
|
Pablo Greco |
e6a3ae |
g_print("cbc(aes128): ");
|
|
Pablo Greco |
e6a3ae |
g_print("Testing chunk_size %zu bytes ", chunk_size);
|
|
Pablo Greco |
e6a3ae |
g_print("done: %.2f MB in %.2f secs: ", total, g_test_timer_last());
|
|
Pablo Greco |
e6a3ae |
@@ -78,7 +78,7 @@ int main(int argc, char **argv)
|
|
Pablo Greco |
e6a3ae |
g_test_init(&argc, &argv, NULL);
|
|
Pablo Greco |
e6a3ae |
g_assert(qcrypto_init(NULL) == 0);
|
|
Pablo Greco |
e6a3ae |
|
|
Pablo Greco |
e6a3ae |
- for (i = 512; i <= (64 * 1204); i *= 2) {
|
|
Pablo Greco |
e6a3ae |
+ for (i = 512; i <= 64 * KiB; i *= 2) {
|
|
Pablo Greco |
e6a3ae |
memset(name, 0 , sizeof(name));
|
|
Pablo Greco |
e6a3ae |
snprintf(name, sizeof(name), "/crypto/cipher/speed-%zu", i);
|
|
Pablo Greco |
e6a3ae |
g_test_add_data_func(name, (void *)i, test_cipher_speed);
|
|
Pablo Greco |
e6a3ae |
diff --git a/tests/benchmark-crypto-hash.c b/tests/benchmark-crypto-hash.c
|
|
Pablo Greco |
e6a3ae |
index 122bfb6..9b6f7a9 100644
|
|
Pablo Greco |
e6a3ae |
--- a/tests/benchmark-crypto-hash.c
|
|
Pablo Greco |
e6a3ae |
+++ b/tests/benchmark-crypto-hash.c
|
|
Pablo Greco |
e6a3ae |
@@ -11,6 +11,7 @@
|
|
Pablo Greco |
e6a3ae |
* top-level directory.
|
|
Pablo Greco |
e6a3ae |
*/
|
|
Pablo Greco |
e6a3ae |
#include "qemu/osdep.h"
|
|
Pablo Greco |
e6a3ae |
+#include "qemu/units.h"
|
|
Pablo Greco |
e6a3ae |
#include "crypto/init.h"
|
|
Pablo Greco |
e6a3ae |
#include "crypto/hash.h"
|
|
Pablo Greco |
e6a3ae |
|
|
Pablo Greco |
e6a3ae |
@@ -39,7 +40,7 @@ static void test_hash_speed(const void *opaque)
|
|
Pablo Greco |
e6a3ae |
total += chunk_size;
|
|
Pablo Greco |
e6a3ae |
} while (g_test_timer_elapsed() < 5.0);
|
|
Pablo Greco |
e6a3ae |
|
|
Pablo Greco |
e6a3ae |
- total /= 1024 * 1024; /* to MB */
|
|
Pablo Greco |
e6a3ae |
+ total /= MiB;
|
|
Pablo Greco |
e6a3ae |
g_print("sha256: ");
|
|
Pablo Greco |
e6a3ae |
g_print("Testing chunk_size %zu bytes ", chunk_size);
|
|
Pablo Greco |
e6a3ae |
g_print("done: %.2f MB in %.2f secs: ", total, g_test_timer_last());
|
|
Pablo Greco |
e6a3ae |
@@ -57,7 +58,7 @@ int main(int argc, char **argv)
|
|
Pablo Greco |
e6a3ae |
g_test_init(&argc, &argv, NULL);
|
|
Pablo Greco |
e6a3ae |
g_assert(qcrypto_init(NULL) == 0);
|
|
Pablo Greco |
e6a3ae |
|
|
Pablo Greco |
e6a3ae |
- for (i = 512; i <= (64 * 1204); i *= 2) {
|
|
Pablo Greco |
e6a3ae |
+ for (i = 512; i <= 64 * KiB; i *= 2) {
|
|
Pablo Greco |
e6a3ae |
memset(name, 0 , sizeof(name));
|
|
Pablo Greco |
e6a3ae |
snprintf(name, sizeof(name), "/crypto/hash/speed-%zu", i);
|
|
Pablo Greco |
e6a3ae |
g_test_add_data_func(name, (void *)i, test_hash_speed);
|
|
Pablo Greco |
e6a3ae |
diff --git a/tests/benchmark-crypto-hmac.c b/tests/benchmark-crypto-hmac.c
|
|
Pablo Greco |
e6a3ae |
index c30250d..f1dfa24 100644
|
|
Pablo Greco |
e6a3ae |
--- a/tests/benchmark-crypto-hmac.c
|
|
Pablo Greco |
e6a3ae |
+++ b/tests/benchmark-crypto-hmac.c
|
|
Pablo Greco |
e6a3ae |
@@ -11,6 +11,7 @@
|
|
Pablo Greco |
e6a3ae |
* top-level directory.
|
|
Pablo Greco |
e6a3ae |
*/
|
|
Pablo Greco |
e6a3ae |
#include "qemu/osdep.h"
|
|
Pablo Greco |
e6a3ae |
+#include "qemu/units.h"
|
|
Pablo Greco |
e6a3ae |
#include "crypto/init.h"
|
|
Pablo Greco |
e6a3ae |
#include "crypto/hmac.h"
|
|
Pablo Greco |
e6a3ae |
|
|
Pablo Greco |
e6a3ae |
@@ -53,8 +54,7 @@ static void test_hmac_speed(const void *opaque)
|
|
Pablo Greco |
e6a3ae |
total += chunk_size;
|
|
Pablo Greco |
e6a3ae |
} while (g_test_timer_elapsed() < 5.0);
|
|
Pablo Greco |
e6a3ae |
|
|
Pablo Greco |
e6a3ae |
- total /= 1024 * 1024; /* to MB */
|
|
Pablo Greco |
e6a3ae |
-
|
|
Pablo Greco |
e6a3ae |
+ total /= MiB;
|
|
Pablo Greco |
e6a3ae |
g_print("hmac(sha256): ");
|
|
Pablo Greco |
e6a3ae |
g_print("Testing chunk_size %zu bytes ", chunk_size);
|
|
Pablo Greco |
e6a3ae |
g_print("done: %.2f MB in %.2f secs: ", total, g_test_timer_last());
|
|
Pablo Greco |
e6a3ae |
@@ -72,7 +72,7 @@ int main(int argc, char **argv)
|
|
Pablo Greco |
e6a3ae |
g_test_init(&argc, &argv, NULL);
|
|
Pablo Greco |
e6a3ae |
g_assert(qcrypto_init(NULL) == 0);
|
|
Pablo Greco |
e6a3ae |
|
|
Pablo Greco |
e6a3ae |
- for (i = 512; i <= (64 * 1204); i *= 2) {
|
|
Pablo Greco |
e6a3ae |
+ for (i = 512; i <= 64 * KiB; i *= 2) {
|
|
Pablo Greco |
e6a3ae |
memset(name, 0 , sizeof(name));
|
|
Pablo Greco |
e6a3ae |
snprintf(name, sizeof(name), "/crypto/hmac/speed-%zu", i);
|
|
Pablo Greco |
e6a3ae |
g_test_add_data_func(name, (void *)i, test_hmac_speed);
|
|
Pablo Greco |
e6a3ae |
--
|
|
Pablo Greco |
e6a3ae |
1.8.3.1
|
|
Pablo Greco |
e6a3ae |
|