diff --git a/aes-32bit/aes.cpp b/aes-32bit/aes.cpp index 0edca5f..acd513a 100644 --- a/aes-32bit/aes.cpp +++ b/aes-32bit/aes.cpp @@ -1,3 +1,4 @@ +#include #include #include #include @@ -195,9 +196,17 @@ int main(int argc, char* argv[]) cycles = std::atoi(argv[1]); } - for (int i = 0; i < cycles; i++) { - uint8_t key[16] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff }; - uint8_t in[16] = { 0xab, 0xcd, 0xef, 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0x01, 0x23, 0x45, 0x67, 0x89}; - aes(in, in, key); + const auto start{std::chrono::steady_clock::now()}; + { + for (int i = 0; i < cycles; i++) { + uint8_t key[16] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff }; + uint8_t in[16] = { 0xab, 0xcd, 0xef, 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0x01, 0x23, 0x45, 0x67, 0x89}; + aes(in, in, key); + } } + const auto end{std::chrono::steady_clock::now()}; + const std::chrono::duration elapsed_seconds{end - start}; + + std::cout << "AES (" << cycles << " runs)\nElapsed time: "; + std::cout << elapsed_seconds.count() << "s\n"; // Before C++20 }