benchmark_main.c 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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. printf("\nBenchmark Test %d:\n", test_num);
  40. benchmark_test(&args);
  41. printf("Benchmark Test %d: Return code %d\n", test_num, args.return_code);
  42. test_num++;
  43. } while(args.return_code == 0);
  44. }
  45. /*
  46. SAMPLE OUTPUT: Freescale K64 running at 96MHz with no MMCAU:
  47. Benchmark Test 0:
  48. AES 25 kB took 0.073 seconds, 0.334 MB/s
  49. ARC4 25 kB took 0.033 seconds, 0.740 MB/s
  50. RABBIT 25 kB took 0.027 seconds, 0.904 MB/s
  51. 3DES 25 kB took 0.375 seconds, 0.065 MB/s
  52. MD5 25 kB took 0.016 seconds, 1.526 MB/s
  53. SHA 25 kB took 0.044 seconds, 0.555 MB/s
  54. SHA-256 25 kB took 0.119 seconds, 0.205 MB/s
  55. RSA 1024 encryption took 91.000 milliseconds, avg over 1 iterations
  56. RSA 1024 decryption took 573.000 milliseconds, avg over 1 iterations
  57. DH 1024 key generation 253.000 milliseconds, avg over 1 iterations
  58. DH 1024 key agreement 311.000 milliseconds, avg over 1 iterations
  59. Benchmark Test 0: Return code 0
  60. SAMPLE OUTPUT: Freescale K64 running at 96MHz with MMCAU enabled:
  61. Benchmark Test 0:
  62. AES 25 kB took 0.019 seconds, 1.285 MB/s
  63. ARC4 25 kB took 0.033 seconds, 0.740 MB/s
  64. RABBIT 25 kB took 0.028 seconds, 0.872 MB/s
  65. 3DES 25 kB took 0.026 seconds, 0.939 MB/s
  66. MD5 25 kB took 0.005 seconds, 4.883 MB/s
  67. SHA 25 kB took 0.008 seconds, 3.052 MB/s
  68. SHA-256 25 kB took 0.013 seconds, 1.878 MB/s
  69. RSA 1024 encryption took 89.000 milliseconds, avg over 1 iterations
  70. RSA 1024 decryption took 573.000 milliseconds, avg over 1 iterations
  71. DH 1024 key generation 250.000 milliseconds, avg over 1 iterations
  72. DH 1024 key agreement 308.000 milliseconds, avg over 1 iterations
  73. Benchmark Test 0: Return code 0
  74. SAMPLE OUTPUT: NXP K82 running at 150Mhz w/MMCAU and LTC
  75. Benchmark Test 0:
  76. RNG 25 kB took 0.026 seconds, 0.939 MB/s
  77. AES enc 25 kB took 0.002 seconds, 12.207 MB/s
  78. AES dec 25 kB took 0.002 seconds, 12.207 MB/s
  79. AES-GCM 25 kB took 0.002 seconds, 12.207 MB/s
  80. AES-CTR 25 kB took 0.003 seconds, 8.138 MB/s
  81. AES-CCM 25 kB took 0.004 seconds, 6.104 MB/s
  82. CHACHA 25 kB took 0.008 seconds, 3.052 MB/s
  83. CHA-POLY 25 kB took 0.013 seconds, 1.878 MB/s
  84. POLY1305 25 kB took 0.003 seconds, 8.138 MB/s
  85. SHA 25 kB took 0.006 seconds, 4.069 MB/s
  86. SHA-256 25 kB took 0.009 seconds, 2.713 MB/s
  87. SHA-384 25 kB took 0.032 seconds, 0.763 MB/s
  88. SHA-512 25 kB took 0.035 seconds, 0.698 MB/s
  89. RSA 2048 public 12.000 milliseconds, avg over 1 iterations
  90. RSA 2048 private 135.000 milliseconds, avg over 1 iterations
  91. ECC 256 key generation 17.400 milliseconds, avg over 5 iterations
  92. EC-DHE key agreement 15.200 milliseconds, avg over 5 iterations
  93. EC-DSA sign time 20.200 milliseconds, avg over 5 iterations
  94. EC-DSA verify time 33.000 milliseconds, avg over 5 iterations
  95. CURVE25519 256 key generation 14.400 milliseconds, avg over 5 iterations
  96. CURVE25519 key agreement 14.400 milliseconds, avg over 5 iterations
  97. ED25519 key generation 14.800 milliseconds, avg over 5 iterations
  98. ED25519 sign time 16.800 milliseconds, avg over 5 iterations
  99. ED25519 verify time 30.400 milliseconds, avg over 5 iterations
  100. Benchmark Test 0: Return code 0
  101. SAMPLE OUTPUT: NXP K82 running at 150Mhz software only
  102. Benchmark Test 0:
  103. RNG 25 kB took 0.035 seconds, 0.698 MB/s
  104. AES enc 25 kB took 0.038 seconds, 0.642 MB/s
  105. AES dec 25 kB took 0.036 seconds, 0.678 MB/s
  106. AES-GCM 25 kB took 0.485 seconds, 0.050 MB/s
  107. AES-CTR 25 kB took 0.038 seconds, 0.642 MB/s
  108. AES-CCM 25 kB took 0.077 seconds, 0.317 MB/s
  109. CHACHA 25 kB took 0.009 seconds, 2.713 MB/s
  110. CHA-POLY 25 kB took 0.013 seconds, 1.878 MB/s
  111. POLY1305 25 kB took 0.003 seconds, 8.138 MB/s
  112. SHA 25 kB took 0.006 seconds, 4.069 MB/s
  113. SHA-256 25 kB took 0.014 seconds, 1.744 MB/s
  114. SHA-384 25 kB took 0.032 seconds, 0.763 MB/s
  115. SHA-512 25 kB took 0.034 seconds, 0.718 MB/s
  116. RSA 1024 encryption took 18.000 milliseconds, avg over 1 iterations
  117. RSA 1024 decryption took 123.000 milliseconds, avg over 1 iterations
  118. RSA 2048 encryption took 63.000 milliseconds, avg over 1 iterations
  119. RSA 2048 decryption took 1011.000 milliseconds, avg over 1 iterations
  120. ECC 256 key generation 180.800 milliseconds, avg over 5 iterations
  121. EC-DHE key agreement 178.600 milliseconds, avg over 5 iterations
  122. EC-DSA sign time 184.600 milliseconds, avg over 5 iterations
  123. EC-DSA verify time 130.200 milliseconds, avg over 5 iterations
  124. CURVE25519 256 key generation 41.800 milliseconds, avg over 5 iterations
  125. CURVE25519 key agreement 41.600 milliseconds, avg over 5 iterations
  126. ED25519 key generation 14.800 milliseconds, avg over 5 iterations
  127. ED25519 sign time 16.600 milliseconds, avg over 5 iterations
  128. ED25519 verify time 48.000 milliseconds, avg over 5 iterations
  129. Benchmark Test 0: Return code 0
  130. */