diff --git a/primary_operations_test.cpp b/primary_operations_test.cpp new file mode 100644 index 0000000..53a8e16 --- /dev/null +++ b/primary_operations_test.cpp @@ -0,0 +1,50 @@ +#include +#include +#include +#include +using namespace std::chrono_literals; + +template +void time_type(const size_t loop,T init,T incr ,const std::function lambda, std::string name) +{ + T p; + auto begin = std::chrono::high_resolution_clock::now(); + for(T i=0;i(end-begin).count() + <<"µs" + <(10000,1,1,[](int a,int b)->int {return a+b;}, "int +"); + time_type(10000,20000,1,[](int a,int b)->int {return a-b;}, "int -"); + time_type(10000,1,2,[](int a,int b)->int {return a*b;}, "int *"); + time_type(10000,99999999,2,[](int a,int b)->int {return a/b;}, "int /"); + + time_type(10000,1,0.5,[](float a,float b)->float {return a+b;}, "float +"); + time_type(10000,20000,1.14,[](float a,float b)->float {return a-b;}, "float -"); + time_type(10000,1,1.25,[](float a,float b)->float {return a*b;}, "float *"); + time_type(10000,99999999,1.25,[](float a,float b)->float {return a/b;}, "float /"); + + time_type(10000,1,0.5,[](double a,double b)->double {return a+b;}, "double +"); + time_type(10000,20000,1.14,[](double a,double b)->double {return a-b;}, "double -"); + time_type(10000,1,1.25,[](double a,double b)->double {return a*b;}, "double *"); + time_type(10000,99999999,1.25,[](double a,double b)->double {return a/b;}, "double /"); +} \ No newline at end of file