Add HMAC benchmarks.
This commit is contained in:
parent
ad4638d3c9
commit
b100073418
@ -112,6 +112,46 @@ class SHA512ShortBench final : public td::Benchmark {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class HmacSha256ShortBench final : public td::Benchmark {
|
||||||
|
public:
|
||||||
|
alignas(64) unsigned char data[SHORT_DATA_SIZE];
|
||||||
|
|
||||||
|
std::string get_description() const final {
|
||||||
|
return PSTRING() << "HMAC-SHA256 [" << SHORT_DATA_SIZE << "B]";
|
||||||
|
}
|
||||||
|
|
||||||
|
void start_up() final {
|
||||||
|
std::fill(std::begin(data), std::end(data), static_cast<unsigned char>(123));
|
||||||
|
}
|
||||||
|
|
||||||
|
void run(int n) final {
|
||||||
|
unsigned char md[32];
|
||||||
|
for (int i = 0; i < n; i++) {
|
||||||
|
td::hmac_sha256(td::Slice(data, SHORT_DATA_SIZE), td::Slice(data, SHORT_DATA_SIZE), td::MutableSlice(md, 32));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class HmacSha512ShortBench final : public td::Benchmark {
|
||||||
|
public:
|
||||||
|
alignas(64) unsigned char data[SHORT_DATA_SIZE];
|
||||||
|
|
||||||
|
std::string get_description() const final {
|
||||||
|
return PSTRING() << "HMAC-SHA512 [" << SHORT_DATA_SIZE << "B]";
|
||||||
|
}
|
||||||
|
|
||||||
|
void start_up() final {
|
||||||
|
std::fill(std::begin(data), std::end(data), static_cast<unsigned char>(123));
|
||||||
|
}
|
||||||
|
|
||||||
|
void run(int n) final {
|
||||||
|
unsigned char md[32];
|
||||||
|
for (int i = 0; i < n; i++) {
|
||||||
|
td::hmac_sha256(td::Slice(data, SHORT_DATA_SIZE), td::Slice(data, SHORT_DATA_SIZE), td::MutableSlice(md, 32));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
class AesEcbBench final : public td::Benchmark {
|
class AesEcbBench final : public td::Benchmark {
|
||||||
public:
|
public:
|
||||||
alignas(64) unsigned char data[DATA_SIZE];
|
alignas(64) unsigned char data[DATA_SIZE];
|
||||||
@ -478,6 +518,8 @@ int main() {
|
|||||||
td::bench(SHA1ShortBench());
|
td::bench(SHA1ShortBench());
|
||||||
td::bench(SHA256ShortBench());
|
td::bench(SHA256ShortBench());
|
||||||
td::bench(SHA512ShortBench());
|
td::bench(SHA512ShortBench());
|
||||||
|
td::bench(HmacSha256ShortBench());
|
||||||
|
td::bench(HmacSha512ShortBench());
|
||||||
td::bench(Crc32Bench());
|
td::bench(Crc32Bench());
|
||||||
td::bench(Crc64Bench());
|
td::bench(Crc64Bench());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user