-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaffine_driver.cpp
36 lines (29 loc) · 1.12 KB
/
affine_driver.cpp
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
#include "affine.hpp"
#include <array>
#include <cassert>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <chrono>
#include "gf2.hpp"
int main(int argc, char** argv) {
const size_t loops = 1000000;
uint8_t affine = 0x1F;
uint8_t coefficient = 0xC6;
auto a = affine_transform(0xCA, affine, coefficient);
size_t x = 0;
std::cout << std::setw(2) << std::setfill('0') << (int)a << std::endl;
std::array<uint8_t, 256> input;
std::generate(input.begin(), input.end(), [n=0]() mutable { return n++; });
std::cout << std::chrono::high_resolution_clock::period::den << std::endl;
auto start_time = std::chrono::high_resolution_clock::now();
for(size_t i = 0; i < loops; ++i ) {
for(auto val : input) {
x += affine_transform(val, affine, coefficient);
}
}
auto end_time = std::chrono::high_resolution_clock::now();
std::cout << "Original: sum " << x << std::endl;
std::cout << std::chrono::duration_cast<std::chrono::microseconds>(end_time - start_time).count()/(double)loops << " seconds per iteration" << std::endl;
return 0;
}