mbench.cpp 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #include <library/cpp/testing/benchmark/bench.h>
  2. #include <library/cpp/digest/argonish/argon2.h>
  3. Y_CPU_BENCHMARK(Argon2d_2048_REF, iface) {
  4. NArgonish::TArgon2Factory factory;
  5. auto argon2 = factory.Create(NArgonish::EInstructionSet::REF, NArgonish::EArgon2Type::Argon2d, 1, 2048, 1);
  6. ui8 password[16] = {0x0};
  7. ui8 salt[16] = {0x01};
  8. ui8 result[16] = {0};
  9. for (ui64 i = 0; i < iface.Iterations(); ++i) {
  10. argon2->Hash(password, sizeof(password), salt, sizeof(salt), result, sizeof(result));
  11. }
  12. }
  13. #if !defined(_arm64_)
  14. Y_CPU_BENCHMARK(Argon2d_2048_SSE2, iface) {
  15. NArgonish::TArgon2Factory factory;
  16. auto argon2 = factory.Create(NArgonish::EInstructionSet::SSE2, NArgonish::EArgon2Type::Argon2d, 1, 2048, 1);
  17. ui8 password[16] = {0x0};
  18. ui8 salt[16] = {0x01};
  19. ui8 result[16] = {0};
  20. for (ui64 i = 0; i < iface.Iterations(); ++i) {
  21. argon2->Hash(password, sizeof(password), salt, sizeof(salt), result, sizeof(result));
  22. }
  23. }
  24. Y_CPU_BENCHMARK(Argon2d_2048_SSSE3, iface) {
  25. NArgonish::TArgon2Factory factory;
  26. auto argon2 = factory.Create(NArgonish::EInstructionSet::SSSE3, NArgonish::EArgon2Type::Argon2d, 1, 2048, 1);
  27. ui8 password[16] = {0x0};
  28. ui8 salt[16] = {0x01};
  29. ui8 result[16] = {0};
  30. for (ui64 i = 0; i < iface.Iterations(); ++i) {
  31. argon2->Hash(password, sizeof(password), salt, sizeof(salt), result, sizeof(result));
  32. }
  33. }
  34. Y_CPU_BENCHMARK(Argon2d_2048_SSE41, iface) {
  35. NArgonish::TArgon2Factory factory;
  36. auto argon2 = factory.Create(NArgonish::EInstructionSet::SSE41, NArgonish::EArgon2Type::Argon2d, 1, 2048, 1);
  37. ui8 password[16] = {0x0};
  38. ui8 salt[16] = {0x01};
  39. ui8 result[16] = {0};
  40. for (ui64 i = 0; i < iface.Iterations(); ++i) {
  41. argon2->Hash(password, sizeof(password), salt, sizeof(salt), result, sizeof(result));
  42. }
  43. }
  44. Y_CPU_BENCHMARK(Argon2d_2048_AVX2, iface) {
  45. NArgonish::TArgon2Factory factory;
  46. auto argon2 = factory.Create(NArgonish::EInstructionSet::AVX2, NArgonish::EArgon2Type::Argon2d, 1, 2048, 1);
  47. ui8 password[16] = {0x0};
  48. ui8 salt[16] = {0x01};
  49. ui8 result[16] = {0};
  50. for (ui64 i = 0; i < iface.Iterations(); ++i) {
  51. argon2->Hash(password, sizeof(password), salt, sizeof(salt), result, sizeof(result));
  52. }
  53. }
  54. #endif