aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/digest/argonish/benchmark/mbench.cpp
blob: 178c1169c9665e2de6485fdba988fd5089c89b12 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <library/cpp/testing/benchmark/bench.h>
#include <library/cpp/digest/argonish/argon2.h>

Y_CPU_BENCHMARK(Argon2d_2048_REF, iface) {
    NArgonish::TArgon2Factory factory;
    auto argon2 = factory.Create(NArgonish::EInstructionSet::REF, NArgonish::EArgon2Type::Argon2d, 1, 2048, 1);
    ui8 password[16] = {0x0};
    ui8 salt[16] = {0x01};
    ui8 result[16] = {0};

    for (ui64 i = 0; i < iface.Iterations(); ++i) {
        argon2->Hash(password, sizeof(password), salt, sizeof(salt), result, sizeof(result));
    }
}

#if !defined(_arm64_)
Y_CPU_BENCHMARK(Argon2d_2048_SSE2, iface) {
    NArgonish::TArgon2Factory factory;
    auto argon2 = factory.Create(NArgonish::EInstructionSet::SSE2, NArgonish::EArgon2Type::Argon2d, 1, 2048, 1);
    ui8 password[16] = {0x0};
    ui8 salt[16] = {0x01};
    ui8 result[16] = {0};

    for (ui64 i = 0; i < iface.Iterations(); ++i) {
        argon2->Hash(password, sizeof(password), salt, sizeof(salt), result, sizeof(result));
    }
}

Y_CPU_BENCHMARK(Argon2d_2048_SSSE3, iface) {
    NArgonish::TArgon2Factory factory;
    auto argon2 = factory.Create(NArgonish::EInstructionSet::SSSE3, NArgonish::EArgon2Type::Argon2d, 1, 2048, 1);
    ui8 password[16] = {0x0};
    ui8 salt[16] = {0x01};
    ui8 result[16] = {0};

    for (ui64 i = 0; i < iface.Iterations(); ++i) {
        argon2->Hash(password, sizeof(password), salt, sizeof(salt), result, sizeof(result));
    }
}

Y_CPU_BENCHMARK(Argon2d_2048_SSE41, iface) {
    NArgonish::TArgon2Factory factory;
    auto argon2 = factory.Create(NArgonish::EInstructionSet::SSE41, NArgonish::EArgon2Type::Argon2d, 1, 2048, 1);
    ui8 password[16] = {0x0};
    ui8 salt[16] = {0x01};
    ui8 result[16] = {0};

    for (ui64 i = 0; i < iface.Iterations(); ++i) {
        argon2->Hash(password, sizeof(password), salt, sizeof(salt), result, sizeof(result));
    }
}

Y_CPU_BENCHMARK(Argon2d_2048_AVX2, iface) {
    NArgonish::TArgon2Factory factory;
    auto argon2 = factory.Create(NArgonish::EInstructionSet::AVX2, NArgonish::EArgon2Type::Argon2d, 1, 2048, 1);
    ui8 password[16] = {0x0};
    ui8 salt[16] = {0x01};
    ui8 result[16] = {0};

    for (ui64 i = 0; i < iface.Iterations(); ++i) {
        argon2->Hash(password, sizeof(password), salt, sizeof(salt), result, sizeof(result));
    }
}
#endif