benchmark_main.c 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. /* benchmark_main.c
  2. *
  3. * Copyright (C) 2006-2021 wolfSSL Inc.
  4. *
  5. * This file is part of wolfSSL.
  6. *
  7. * wolfSSL is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * wolfSSL is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
  20. */
  21. #ifdef HAVE_CONFIG_H
  22. #include <config.h>
  23. #endif
  24. #include <wolfssl/wolfcrypt/settings.h>
  25. #include <wolfssl/wolfcrypt/wc_port.h>
  26. #include <wolfcrypt/benchmark/benchmark.h>
  27. #include <stdio.h>
  28. typedef struct func_args {
  29. int argc;
  30. char** argv;
  31. int return_code;
  32. } func_args;
  33. static func_args args = { 0 } ;
  34. extern double current_time(int reset);
  35. void main(void)
  36. {
  37. int test_num = 0;
  38. wolfCrypt_Init(); /* required for ksdk_port_init */
  39. do
  40. {
  41. /* Used for testing, must have a delay so no data is missed while serial is initializing */
  42. #ifdef WOLFSSL_FRDM_K64_JENKINS
  43. /* run once */
  44. if(test_num == 1){
  45. printf("\n&&&&&&&&&&&&& done &&&&&&&&&&&&&&&");
  46. delay_us(1000000);
  47. break;
  48. }
  49. delay_us(1000000); /* 1 second */
  50. #endif
  51. printf("\nBenchmark Test %d:\n", test_num);
  52. benchmark_test(&args);
  53. printf("Benchmark Test %d: Return code %d\n", test_num, args.return_code);
  54. test_num++;
  55. } while(args.return_code == 0);
  56. /*Print this again for redundancy*/
  57. #ifdef WOLFSSL_FRDM_K64_JENKINS
  58. printf("\n&&&&&&&&&&&&&& done &&&&&&&&&&&&&\n");
  59. delay_us(1000000);
  60. #endif
  61. wolfCrypt_Cleanup();
  62. }
  63. /*
  64. SAMPLE OUTPUT: Freescale K64 running at 96MHz with no MMCAU:
  65. Benchmark Test 0:
  66. AES 25 kB took 0.073 seconds, 0.334 MB/s
  67. ARC4 25 kB took 0.033 seconds, 0.740 MB/s
  68. RABBIT 25 kB took 0.027 seconds, 0.904 MB/s
  69. 3DES 25 kB took 0.375 seconds, 0.065 MB/s
  70. MD5 25 kB took 0.016 seconds, 1.526 MB/s
  71. SHA 25 kB took 0.044 seconds, 0.555 MB/s
  72. SHA-256 25 kB took 0.119 seconds, 0.205 MB/s
  73. RSA 1024 encryption took 91.000 milliseconds, avg over 1 iterations
  74. RSA 1024 decryption took 573.000 milliseconds, avg over 1 iterations
  75. DH 1024 key generation 253.000 milliseconds, avg over 1 iterations
  76. DH 1024 key agreement 311.000 milliseconds, avg over 1 iterations
  77. Benchmark Test 0: Return code 0
  78. SAMPLE OUTPUT: Freescale K64 running at 96MHz with MMCAU enabled:
  79. Benchmark Test 0:
  80. AES 25 kB took 0.019 seconds, 1.285 MB/s
  81. ARC4 25 kB took 0.033 seconds, 0.740 MB/s
  82. RABBIT 25 kB took 0.028 seconds, 0.872 MB/s
  83. 3DES 25 kB took 0.026 seconds, 0.939 MB/s
  84. MD5 25 kB took 0.005 seconds, 4.883 MB/s
  85. SHA 25 kB took 0.008 seconds, 3.052 MB/s
  86. SHA-256 25 kB took 0.013 seconds, 1.878 MB/s
  87. RSA 1024 encryption took 89.000 milliseconds, avg over 1 iterations
  88. RSA 1024 decryption took 573.000 milliseconds, avg over 1 iterations
  89. DH 1024 key generation 250.000 milliseconds, avg over 1 iterations
  90. DH 1024 key agreement 308.000 milliseconds, avg over 1 iterations
  91. Benchmark Test 0: Return code 0
  92. SAMPLE OUTPUT: NXP K82 running at 150Mhz w/MMCAU and LTC
  93. Benchmark Test 0:
  94. RNG 25 kB took 0.026 seconds, 0.939 MB/s
  95. AES enc 25 kB took 0.002 seconds, 12.207 MB/s
  96. AES dec 25 kB took 0.002 seconds, 12.207 MB/s
  97. AES-GCM 25 kB took 0.002 seconds, 12.207 MB/s
  98. AES-CTR 25 kB took 0.003 seconds, 8.138 MB/s
  99. AES-CCM 25 kB took 0.004 seconds, 6.104 MB/s
  100. CHACHA 25 kB took 0.008 seconds, 3.052 MB/s
  101. CHA-POLY 25 kB took 0.013 seconds, 1.878 MB/s
  102. POLY1305 25 kB took 0.003 seconds, 8.138 MB/s
  103. SHA 25 kB took 0.006 seconds, 4.069 MB/s
  104. SHA-256 25 kB took 0.009 seconds, 2.713 MB/s
  105. SHA-384 25 kB took 0.032 seconds, 0.763 MB/s
  106. SHA-512 25 kB took 0.035 seconds, 0.698 MB/s
  107. RSA 2048 public 12.000 milliseconds, avg over 1 iterations
  108. RSA 2048 private 135.000 milliseconds, avg over 1 iterations
  109. ECC 256 key generation 17.400 milliseconds, avg over 5 iterations
  110. EC-DHE key agreement 15.200 milliseconds, avg over 5 iterations
  111. EC-DSA sign time 20.200 milliseconds, avg over 5 iterations
  112. EC-DSA verify time 33.000 milliseconds, avg over 5 iterations
  113. CURVE25519 256 key generation 14.400 milliseconds, avg over 5 iterations
  114. CURVE25519 key agreement 14.400 milliseconds, avg over 5 iterations
  115. ED25519 key generation 14.800 milliseconds, avg over 5 iterations
  116. ED25519 sign time 16.800 milliseconds, avg over 5 iterations
  117. ED25519 verify time 30.400 milliseconds, avg over 5 iterations
  118. Benchmark Test 0: Return code 0
  119. SAMPLE OUTPUT: NXP K82 running at 150Mhz software only
  120. Benchmark Test 0:
  121. RNG 25 kB took 0.035 seconds, 0.698 MB/s
  122. AES enc 25 kB took 0.038 seconds, 0.642 MB/s
  123. AES dec 25 kB took 0.036 seconds, 0.678 MB/s
  124. AES-GCM 25 kB took 0.485 seconds, 0.050 MB/s
  125. AES-CTR 25 kB took 0.038 seconds, 0.642 MB/s
  126. AES-CCM 25 kB took 0.077 seconds, 0.317 MB/s
  127. CHACHA 25 kB took 0.009 seconds, 2.713 MB/s
  128. CHA-POLY 25 kB took 0.013 seconds, 1.878 MB/s
  129. POLY1305 25 kB took 0.003 seconds, 8.138 MB/s
  130. SHA 25 kB took 0.006 seconds, 4.069 MB/s
  131. SHA-256 25 kB took 0.014 seconds, 1.744 MB/s
  132. SHA-384 25 kB took 0.032 seconds, 0.763 MB/s
  133. SHA-512 25 kB took 0.034 seconds, 0.718 MB/s
  134. RSA 1024 encryption took 18.000 milliseconds, avg over 1 iterations
  135. RSA 1024 decryption took 123.000 milliseconds, avg over 1 iterations
  136. RSA 2048 encryption took 63.000 milliseconds, avg over 1 iterations
  137. RSA 2048 decryption took 1011.000 milliseconds, avg over 1 iterations
  138. ECC 256 key generation 180.800 milliseconds, avg over 5 iterations
  139. EC-DHE key agreement 178.600 milliseconds, avg over 5 iterations
  140. EC-DSA sign time 184.600 milliseconds, avg over 5 iterations
  141. EC-DSA verify time 130.200 milliseconds, avg over 5 iterations
  142. CURVE25519 256 key generation 41.800 milliseconds, avg over 5 iterations
  143. CURVE25519 key agreement 41.600 milliseconds, avg over 5 iterations
  144. ED25519 key generation 14.800 milliseconds, avg over 5 iterations
  145. ED25519 sign time 16.600 milliseconds, avg over 5 iterations
  146. ED25519 verify time 48.000 milliseconds, avg over 5 iterations
  147. Benchmark Test 0: Return code 0
  148. */