Skip to content

crypto_test: get stats in milliseconds#2372

Merged
nkaje merged 1 commit into
apache:masterfrom
nkaje:crypto_test_milliseconds
Sep 9, 2020
Merged

crypto_test: get stats in milliseconds#2372
nkaje merged 1 commit into
apache:masterfrom
nkaje:crypto_test_milliseconds

Conversation

@nkaje
Copy link
Copy Markdown

@nkaje nkaje commented Sep 8, 2020

Along with ticks, print in milliseconds as well.

Signed-off-by: Naveen Kaje naveen.kaje@juul.com

@nkaje
Copy link
Copy Markdown
Author

nkaje commented Sep 8, 2020

Test output

=== Test vectors ===
AES-128-ECB enc
        vector 0: ok, sz=16
        vector 1: ok, sz=16
        vector 2: ok, sz=16
        vector 3: ok, sz=16
AES-128-ECB dec
        vector 0: ok, sz=16
        vector 1: ok, sz=16
        vector 2: ok, sz=16
        vector 3: ok, sz=16
AES-128-CBC enc
        vector 0: ok, sz=16
        vector 1: ok, sz=16
        vector 2: ok, sz=16
        vector 3: ok, sz=16
AES-128-CBC dec
        vector 0: ok, sz=16
        vector 1: ok, sz=16
        vector 2: ok, sz=16
        vector 3: ok, sz=16
AES-128-CTR enc
        vector 0: ok, sz=16
        vector 1: ok, sz=16
        vector 2: ok, sz=8
        vector 3: ok, sz=16
AES-128-CTR dec
        vector 0: ok, sz=16
        vector 1: ok, sz=16
        vector 2: ok, sz=8
        vector 3: ok, sz=16

=== In-place encrypt/decrypt ===
AES-128-ECB enc: ok
AES-128-ECB dec: ok
AES-128-CBC enc: ok
AES-128-CBC dec: ok
AES-128-CTR enc: ok
AES-128-CTR dec: ok

=== iovec encrypt/decrypt ===
iov AES-128-ECB enc: ok
iov AES-128-ECB dec: ok
iov AES-128-CBC enc: ok
iov AES-128-CBC dec: ok
iov AES-128-CTR enc: ok
iov AES-128-CTR dec: ok

=== Benchmarks - iteration 1 ===
CRYPTO - running 30 iterations of 4096 block encrypt... done in 30 ticks / 234 ms
MBEDTLS - running 30 iterations of 4096 block encrypt... done in 62 ticks / 484 ms
TINYCRYPT - running 30 iterations of 4096 block encrypt... done in 358 ticks / 2796 ms

=== Benchmarks - iteration 2 ===
CRYPTO - running 30 iterations of 4096 block encrypt... done in 30 ticks / 234 ms
MBEDTLS - running 30 iterations of 4096 block encrypt... done in 62 ticks / 484 ms
TINYCRYPT - running 30 iterations of 4096 block encrypt... done in 358 ticks / 2796 ms

=== Benchmarks - iteration 3 ===
CRYPTO - running 30 iterations of 4096 block encrypt... done in 30 ticks / 234 ms
MBEDTLS - running 30 iterations of 4096 block encrypt... done in 62 ticks / 484 ms
TINYCRYPT - running 30 iterations of 4096 block encrypt... done in 358 ticks / 2796 ms

=== CRYPTO benchmarks ===
AES-128-CBC - running 50 iterations of 4096 block encrypt... done in 54 ticks / 421 ms
AES-128-CTR - running 50 iterations of 4096 block encrypt... done in 54 ticks / 421 ms

=== Concurrency [8 tasks] ===
task0 [0 fails / 256 ok] done
task1 [0 fails / 256 ok] done
task2 [0 fails / 256 ok] done
task3 [0 fails / 256 ok] done
task4 [0 fails / 256 ok] done
task5 [0 fails / 256 ok] done
task6 [0 fails / 256 ok] done
task7 [0 fails / 256 ok] done

@nkaje nkaje requested a review from utzig September 8, 2020 17:19
Comment thread apps/crypto_test/src/main.c Outdated
e = os_time_get() - t;
ret = os_time_ticks_to_ms(e, &ms);
assert(ret == 0);
printf("done in %lu ticks / %lu ms\n", e, ms);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When RISCV (unlike ARM) gcc compiler is used, uint32_t is not unsigned long int but just unsigned int.
Usage of "%lu" will lead to warnings there.
I would suggest to use PRIu32 or cast to avoid future warning fixes.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

Along with ticks, print in milliseconds as well.
Use PRIu32 specifier for compiler compatibility.

Signed-off-by: Naveen Kaje <naveen.kaje@juul.com>
@nkaje nkaje force-pushed the crypto_test_milliseconds branch from f5dc058 to 788ab4d Compare September 9, 2020 12:15
Copy link
Copy Markdown
Contributor

@kasjer kasjer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@apache-mynewt-bot
Copy link
Copy Markdown

Style check summary

Our coding style is here!

apps/crypto_test/src/main.c

Details
@@ -199,7 +199,7 @@
         sz = crypto_encrypt_custom(crypto, algo, mode, key, keylen, ivp,
                 inbuf, outbuf, asksz);
         if (sz == asksz && memcmp(outbuf, vector->cipher, sz) == 0) {
-            printf("ok, sz=%"PRIu32"\n", sz);
+            printf("ok, sz=%" PRIu32 "\n", sz);
         } else {
             printf("fail\n");
         }
@@ -224,7 +224,7 @@
         sz = crypto_decrypt_custom(crypto, algo, mode, key, keylen, ivp,
                 inbuf, outbuf, asksz);
         if (sz == asksz && memcmp(outbuf, vector->plain, sz) == 0) {
-            printf("ok, sz=%"PRIu32"\n", sz);
+            printf("ok, sz=%" PRIu32 "\n", sz);
         } else {
             printf("fail\n");
         }
@@ -291,7 +291,7 @@
     e = os_time_get() - t;
     ret = os_time_ticks_to_ms(e, &ms);
     assert(ret == 0);
-    printf("done in %"PRIu32" ticks / %"PRIu32" ms\n", e, ms);
+    printf("done in %" PRIu32 " ticks / %" PRIu32 " ms\n", e, ms);
 }
 
 static void
@@ -326,7 +326,7 @@
     e = os_time_get() - t;
     ret = os_time_ticks_to_ms(e, &ms);
     assert(ret == 0);
-    printf("done in %"PRIu32" ticks / %"PRIu32" ms\n", e, ms);
+    printf("done in %" PRIu32 " ticks / %" PRIu32 " ms\n", e, ms);
 }
 
 static void
@@ -361,7 +361,7 @@
     e = os_time_get() - t;
     ret = os_time_ticks_to_ms(e, &ms);
     assert(ret == 0);
-    printf("done in %"PRIu32" ticks / %"PRIu32" ms\n", e, ms);
+    printf("done in %" PRIu32 " ticks / %" PRIu32 " ms\n", e, ms);
 }
 #endif /* MYNEWT_VAL(CRYPTOTEST_BENCHMARK) */
 

@nkaje nkaje merged commit 2163dff into apache:master Sep 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants