diff --git a/Benchmarks/benchmark.cpp b/Benchmarks/benchmarks.cpp similarity index 95% rename from Benchmarks/benchmark.cpp rename to Benchmarks/benchmarks.cpp index b9ebc29..f1bcb76 100644 --- a/Benchmarks/benchmark.cpp +++ b/Benchmarks/benchmarks.cpp @@ -37,6 +37,7 @@ std::pair norm2_operation(void); std::pair norm_ext_operation(void); std::pair norm2_ext_operation(void); std::pair angle_operation(void); +std::pair angle_ext_operation(void); std::pair make_unit_operation(void); std::pair make_unit_ext_operation(void); @@ -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()); @@ -329,6 +331,19 @@ std::pair norm2_ext_operation(void){ return std::make_pair(average(times), standard_deviation(times)); } std::pair angle_operation(void){ + std::array 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 diff = end-start; + i=std::chrono::duration_cast(diff).count(); + } + return std::make_pair(average(times), standard_deviation(times)); +} +std::pair angle_ext_operation(void){ std::array times; vector3D v; v.load(1.5,1,0.2); vector3D u; u.load(4.5,-1,-0.2); diff --git a/Makefile b/Makefile index c0e31ef..fdaa819 100644 --- a/Makefile +++ b/Makefile @@ -10,14 +10,21 @@ # * along with this program. If not, see 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 diff --git a/Tests/Makefile b/Tests/Makefile deleted file mode 100644 index 574e6bb..0000000 --- a/Tests/Makefile +++ /dev/null @@ -1,22 +0,0 @@ -#A C++ fast and lightweight 3D vector library. -#Optimized to be as fast as possible maintaining great usability. -# -# * This file is part of the Vector3D distribution (https://github.com/cdelv/Vector3D). -# * Copyright (c) 2022 Carlos Andres del Valle. -# * -# *Vector3D is under the terms of the BSD-3 license. We welcome feedback and contributions. -# * -# * You should have received a copy of the BSD3 Public License -# * along with this program. If not, see LICENSE. -# */ - -all: test - -test: test1.x - -test1.x: Test1.cpp - g++ $^ -o $@ -lgtest - ./$@ - -clean: - rm -f *.x *.o a.out