Skip to content

Commit

Permalink
makefile for benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
cdelv committed Sep 5, 2022
1 parent 4b0d58c commit a053a5e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 25 deletions.
17 changes: 16 additions & 1 deletion Benchmarks/benchmark.cpp → Benchmarks/benchmarks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ std::pair <double,double> norm2_operation(void);
std::pair <double,double> norm_ext_operation(void);
std::pair <double,double> norm2_ext_operation(void);
std::pair <double,double> angle_operation(void);
std::pair <double,double> angle_ext_operation(void);
std::pair <double,double> make_unit_operation(void);
std::pair <double,double> make_unit_ext_operation(void);

Expand All @@ -61,7 +62,8 @@ int main(void)
print_report("v.norm2() average time: ",norm2_operation());
print_report("norm(v) average time: ",norm_ext_operation());
print_report("norm2(v) average time: ",norm2_ext_operation());
print_report("angle(v,u) average time: ",angle_operation());
print_report("v.angle(u) average time: ",angle_operation());
print_report("angle(v,u) average time: ",angle_ext_operation());
print_report("v.unit() average time: ",make_unit_operation());
print_report("unit(v) average time: ",make_unit_ext_operation());

Expand Down Expand Up @@ -329,6 +331,19 @@ std::pair <double,double> norm2_ext_operation(void){
return std::make_pair(average(times), standard_deviation(times));
}
std::pair <double,double> angle_operation(void){
std::array<double, samples> times;
vector3D v; v.load(1.5,1,0.2);
vector3D u; u.load(4.5,-1,-0.2);
for (auto &i : times){
auto start = std::chrono::steady_clock::now();
v.angle(u);
auto end = std::chrono::steady_clock::now();
std::chrono::duration<double> diff = end-start;
i=std::chrono::duration_cast<std::chrono::nanoseconds>(diff).count();
}
return std::make_pair(average(times), standard_deviation(times));
}
std::pair <double,double> angle_ext_operation(void){
std::array<double, samples> times;
vector3D v; v.load(1.5,1,0.2);
vector3D u; u.load(4.5,-1,-0.2);
Expand Down
11 changes: 9 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,21 @@
# * along with this program. If not, see <https://github.com/cdelv/Vector3D> LICENSE.
# */

all: test

test: test1.x

test1.x: Tests/Test1.cpp
@g++ $^ -o $@ -lgtest -pthread
@./$@
@rm $@

benchmark: benchmark.x

benchmark.x: Benchmarks/benchmarks.cpp
@g++ $^ -o $@
@./$@
@rm $@

clean:
@rm -f *.x *.o a.out
@rm -f Tests/*.x Tests/*.o Tests/a.out
@rm -f Benchmarks/*.x Benchmarks/*.o Benchmarks/a.out
22 changes: 0 additions & 22 deletions Tests/Makefile

This file was deleted.

0 comments on commit a053a5e

Please sign in to comment.