benchmark_main.c 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. /* benchmark_main.c
  2. *
  3. * Copyright (C) 2006-2017 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 <wolfcrypt/benchmark/benchmark.h>
  26. #include <stdio.h>
  27. typedef struct func_args {
  28. int argc;
  29. char** argv;
  30. int return_code;
  31. } func_args;
  32. static func_args args = { 0 } ;
  33. extern double current_time(int reset);
  34. void main(void)
  35. {
  36. int test_num = 0;
  37. do
  38. {
  39. /* Used for testing, must have a delay so no data is missed while serial is initializing */
  40. #ifdef WOLFSSL_FRDM_K64_JENKINS
  41. if(test_num == 2){
  42. break;
  43. }
  44. delay_us(1000000);
  45. #endif
  46. printf("\nBenchmark Test %d:\n", test_num);
  47. benchmark_test(&args);
  48. printf("Benchmark Test %d: Return code %d\n", test_num, args.return_code);
  49. test_num++;
  50. } while(args.return_code == 0);
  51. }
  52. /*
  53. SAMPLE OUTPUT: Freescale K64 running at 96MHz with no MMCAU:
  54. Benchmark Test 0:
  55. AES 25 kB took 0.073 seconds, 0.334 MB/s
  56. ARC4 25 kB took 0.033 seconds, 0.740 MB/s
  57. RABBIT 25 kB took 0.027 seconds, 0.904 MB/s
  58. 3DES 25 kB took 0.375 seconds, 0.065 MB/s
  59. MD5 25 kB took 0.016 seconds, 1.526 MB/s
  60. SHA 25 kB took 0.044 seconds, 0.555 MB/s
  61. SHA-256 25 kB took 0.119 seconds, 0.205 MB/s
  62. RSA 1024 encryption took 91.000 milliseconds, avg over 1 iterations
  63. RSA 1024 decryption took 573.000 milliseconds, avg over 1 iterations
  64. DH 1024 key generation 253.000 milliseconds, avg over 1 iterations
  65. DH 1024 key agreement 311.000 milliseconds, avg over 1 iterations
  66. Benchmark Test 0: Return code 0
  67. SAMPLE OUTPUT: Freescale K64 running at 96MHz with MMCAU enabled:
  68. Benchmark Test 0:
  69. AES 25 kB took 0.019 seconds, 1.285 MB/s
  70. ARC4 25 kB took 0.033 seconds, 0.740 MB/s
  71. RABBIT 25 kB took 0.028 seconds, 0.872 MB/s
  72. 3DES 25 kB took 0.026 seconds, 0.939 MB/s
  73. MD5 25 kB took 0.005 seconds, 4.883 MB/s
  74. SHA 25 kB took 0.008 seconds, 3.052 MB/s
  75. SHA-256 25 kB took 0.013 seconds, 1.878 MB/s
  76. RSA 1024 encryption took 89.000 milliseconds, avg over 1 iterations
  77. RSA 1024 decryption took 573.000 milliseconds, avg over 1 iterations
  78. DH 1024 key generation 250.000 milliseconds, avg over 1 iterations
  79. DH 1024 key agreement 308.000 milliseconds, avg over 1 iterations
  80. Benchmark Test 0: Return code 0
  81. SAMPLE OUTPUT: NXP K82 running at 150Mhz w/MMCAU and LTC
  82. Benchmark Test 0:
  83. RNG 25 kB took 0.026 seconds, 0.939 MB/s
  84. AES enc 25 kB took 0.002 seconds, 12.207 MB/s
  85. AES dec 25 kB took 0.002 seconds, 12.207 MB/s
  86. AES-GCM 25 kB took 0.002 seconds, 12.207 MB/s
  87. AES-CTR 25 kB took 0.003 seconds, 8.138 MB/s
  88. AES-CCM 25 kB took 0.004 seconds, 6.104 MB/s
  89. CHACHA 25 kB took 0.008 seconds, 3.052 MB/s
  90. CHA-POLY 25 kB took 0.013 seconds, 1.878 MB/s
  91. POLY1305 25 kB took 0.003 seconds, 8.138 MB/s
  92. SHA 25 kB took 0.006 seconds, 4.069 MB/s
  93. SHA-256 25 kB took 0.009 seconds, 2.713 MB/s
  94. SHA-384 25 kB took 0.032 seconds, 0.763 MB/s
  95. SHA-512 25 kB took 0.035 seconds, 0.698 MB/s
  96. RSA 2048 public 12.000 milliseconds, avg over 1 iterations
  97. RSA 2048 private 135.000 milliseconds, avg over 1 iterations
  98. ECC 256 key generation 17.400 milliseconds, avg over 5 iterations
  99. EC-DHE key agreement 15.200 milliseconds, avg over 5 iterations
  100. EC-DSA sign time 20.200 milliseconds, avg over 5 iterations
  101. EC-DSA verify time 33.000 milliseconds, avg over 5 iterations
  102. CURVE25519 256 key generation 14.400 milliseconds, avg over 5 iterations
  103. CURVE25519 key agreement 14.400 milliseconds, avg over 5 iterations
  104. ED25519 key generation 14.800 milliseconds, avg over 5 iterations
  105. ED25519 sign time 16.800 milliseconds, avg over 5 iterations
  106. ED25519 verify time 30.400 milliseconds, avg over 5 iterations
  107. Benchmark Test 0: Return code 0
  108. SAMPLE OUTPUT: NXP K82 running at 150Mhz software only
  109. Benchmark Test 0:
  110. RNG 25 kB took 0.035 seconds, 0.698 MB/s
  111. AES enc 25 kB took 0.038 seconds, 0.642 MB/s
  112. AES dec 25 kB took 0.036 seconds, 0.678 MB/s
  113. AES-GCM 25 kB took 0.485 seconds, 0.050 MB/s
  114. AES-CTR 25 kB took 0.038 seconds, 0.642 MB/s
  115. AES-CCM 25 kB took 0.077 seconds, 0.317 MB/s
  116. CHACHA 25 kB took 0.009 seconds, 2.713 MB/s
  117. CHA-POLY 25 kB took 0.013 seconds, 1.878 MB/s
  118. POLY1305 25 kB took 0.003 seconds, 8.138 MB/s
  119. SHA 25 kB took 0.006 seconds, 4.069 MB/s
  120. SHA-256 25 kB took 0.014 seconds, 1.744 MB/s
  121. SHA-384 25 kB took 0.032 seconds, 0.763 MB/s
  122. SHA-512 25 kB took 0.034 seconds, 0.718 MB/s
  123. RSA 1024 encryption took 18.000 milliseconds, avg over 1 iterations
  124. RSA 1024 decryption took 123.000 milliseconds, avg over 1 iterations
  125. RSA 2048 encryption took 63.000 milliseconds, avg over 1 iterations
  126. RSA 2048 decryption took 1011.000 milliseconds, avg over 1 iterations
  127. ECC 256 key generation 180.800 milliseconds, avg over 5 iterations
  128. EC-DHE key agreement 178.600 milliseconds, avg over 5 iterations
  129. EC-DSA sign time 184.600 milliseconds, avg over 5 iterations
  130. EC-DSA verify time 130.200 milliseconds, avg over 5 iterations
  131. CURVE25519 256 key generation 41.800 milliseconds, avg over 5 iterations
  132. CURVE25519 key agreement 41.600 milliseconds, avg over 5 iterations
  133. ED25519 key generation 14.800 milliseconds, avg over 5 iterations
  134. ED25519 sign time 16.600 milliseconds, avg over 5 iterations
  135. ED25519 verify time 48.000 milliseconds, avg over 5 iterations
  136. Benchmark Test 0: Return code 0
  137. */