Add AES CBC benchmark.

GitOrigin-RevId: 1341d108549c70d9d0b35904eb6389e7589452fc
This commit is contained in:
levlam 2020-09-24 14:21:46 +03:00
parent 5c0d2eb050
commit 78ca715746

View File

@ -206,14 +206,40 @@ class AesCtrOpenSSLBench : public td::Benchmark {
}
};
class AesCbcBench : public td::Benchmark {
class AesCbcDecryptBench : public td::Benchmark {
public:
alignas(64) unsigned char data[DATA_SIZE];
td::UInt256 key;
td::UInt128 iv;
std::string get_description() const override {
return PSTRING() << "AES CBC OpenSSL [" << (DATA_SIZE >> 10) << "KB]";
return PSTRING() << "AES CBC Decrypt OpenSSL [" << (DATA_SIZE >> 10) << "KB]";
}
void start_up() override {
for (int i = 0; i < DATA_SIZE; i++) {
data[i] = 123;
}
td::Random::secure_bytes(as_slice(key));
td::Random::secure_bytes(as_slice(iv));
}
void run(int n) override {
td::MutableSlice data_slice(data, DATA_SIZE);
for (int i = 0; i < n; i++) {
td::aes_cbc_decrypt(as_slice(key), as_slice(iv), data_slice, data_slice);
}
}
};
class AesCbcEncryptBench : public td::Benchmark {
public:
alignas(64) unsigned char data[DATA_SIZE];
td::UInt256 key;
td::UInt128 iv;
std::string get_description() const override {
return PSTRING() << "AES CBC Encrypt OpenSSL [" << (DATA_SIZE >> 10) << "KB]";
}
void start_up() override {
@ -391,6 +417,8 @@ int main() {
td::bench(AesCtrBench());
td::bench(AesCtrOpenSSLBench());
td::bench(AesCbcDecryptBench());
td::bench(AesCbcEncryptBench());
td::bench(AesIgeShortBench<true>());
td::bench(AesIgeShortBench<false>());
td::bench(AesIgeEncryptBench());