diff --git a/test/metabench/CMakeLists.txt b/test/metabench/CMakeLists.txt index 58fdc464..b8448e3c 100644 --- a/test/metabench/CMakeLists.txt +++ b/test/metabench/CMakeLists.txt @@ -39,14 +39,4 @@ endif() enable_testing() -add_metabench_test(metabench.data.std_ratio "std::ratio" ratio/std_ratio.cpp.erb "[10, 50, 100, 500, 1000]") -add_metabench_test(metabench.data.ratio_type_constexpr "ratio with constexpr" ratio/ratio_type_constexpr.cpp.erb "[10, 50, 100, 500, 1000]") -metabench_add_chart(metabench.chart.ratio - TITLE "Ratio on n operations" - SUBTITLE "(smaller is better)" - DATASETS - metabench.data.std_ratio - metabench.data.ratio_type_constexpr -) - -add_custom_target(metabench DEPENDS metabench.chart.ratio) +add_subdirectory(ratio) diff --git a/test/metabench/ratio/CMakeLists.txt b/test/metabench/ratio/CMakeLists.txt new file mode 100644 index 00000000..e7316786 --- /dev/null +++ b/test/metabench/ratio/CMakeLists.txt @@ -0,0 +1,72 @@ +# The MIT License (MIT) +# +# Copyright (c) 2018 Mateusz Pusz +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + + +add_metabench_test(metabench.data.ratio.create.std_ratio "std::ratio" create_std_ratio.cpp.erb "[10, 100, 1000, 10000]") +add_metabench_test(metabench.data.ratio.create.ratio_type_constexpr "ratio with constexpr" create_ratio_type_constexpr.cpp.erb "[10, 100, 1000, 10000]") +metabench_add_chart(metabench.chart.ratio.create + TITLE "Creation on 2*N ratios" + SUBTITLE "(smaller is better)" + DATASETS + metabench.data.ratio.create.std_ratio + metabench.data.ratio.create.ratio_type_constexpr +) + +add_metabench_test(metabench.data.ratio.multiply_divide.std_ratio "std::ratio" all_std_ratio.cpp.erb "[10, 50, 100, 500, 1000]") +add_metabench_test(metabench.data.ratio.multiply_divide.ratio_type_constexpr "ratio with constexpr" all_ratio_type_constexpr.cpp.erb "[10, 50, 100, 500, 1000]") +metabench_add_chart(metabench.chart.ratio.multiply_divide + TITLE "N ratio multiply + divide operations" + SUBTITLE "(smaller is better)" + DATASETS + metabench.data.ratio.multiply_divide.std_ratio + metabench.data.ratio.multiply_divide.ratio_type_constexpr +) + +add_metabench_test(metabench.data.ratio.common_ratio.std_ratio "std::ratio" all_std_ratio.cpp.erb "[10, 50, 100, 500, 1000]") +add_metabench_test(metabench.data.ratio.common_ratio.ratio_type_constexpr "ratio with constexpr" all_ratio_type_constexpr.cpp.erb "[10, 50, 100, 500, 1000]") +metabench_add_chart(metabench.chart.ratio.common_ratio + TITLE "N common_ratio operations" + SUBTITLE "(smaller is better)" + DATASETS + metabench.data.ratio.common_ratio.std_ratio + metabench.data.ratio.common_ratio.ratio_type_constexpr +) + +add_metabench_test(metabench.data.ratio.all.std_ratio "std::ratio" all_std_ratio.cpp.erb "[10, 50, 100, 500, 1000]") +add_metabench_test(metabench.data.ratio.all.ratio_type_constexpr "ratio with constexpr" all_ratio_type_constexpr.cpp.erb "[10, 50, 100, 500, 1000]") +metabench_add_chart(metabench.chart.ratio.all + TITLE "N x all ratio operations" + SUBTITLE "(smaller is better)" + DATASETS + metabench.data.ratio.all.std_ratio + metabench.data.ratio.all.ratio_type_constexpr +) + +add_custom_target(metabench.chart.ratio + DEPENDS + metabench.chart.ratio.create + metabench.chart.ratio.multiply_divide + metabench.chart.ratio.common_ratio + metabench.chart.ratio.all +) + +add_custom_target(metabench DEPENDS metabench.chart.ratio) diff --git a/test/metabench/ratio/all_ratio_type_constexpr.cpp.erb b/test/metabench/ratio/all_ratio_type_constexpr.cpp.erb new file mode 100644 index 00000000..cff47d9e --- /dev/null +++ b/test/metabench/ratio/all_ratio_type_constexpr.cpp.erb @@ -0,0 +1,20 @@ +#include "ratio_type_constexpr.h" + +<% (1..n).each do |i| %> + struct test<%= i %> { +#if defined(METABENCH) + using r1 = units::ratio<<%= i %>, <%= n + 1 - i %>>; + using r2 = units::ratio<<%= n + 1 - i %>, <%= i %>>; + + using r3 = units::ratio_multiply; + using r4 = units::ratio_divide; + + using r5 = units::common_ratio_t; +#endif + }; +<% end %> + + +int main() +{ +} diff --git a/test/metabench/ratio/std_ratio.cpp.erb b/test/metabench/ratio/all_std_ratio.cpp.erb similarity index 100% rename from test/metabench/ratio/std_ratio.cpp.erb rename to test/metabench/ratio/all_std_ratio.cpp.erb index 79ac2a44..851b7256 100644 --- a/test/metabench/ratio/std_ratio.cpp.erb +++ b/test/metabench/ratio/all_std_ratio.cpp.erb @@ -1,8 +1,8 @@ #include "std_ratio.h" -#if defined(METABENCH) <% (1..n).each do |i| %> struct test<%= i %> { +#if defined(METABENCH) using r1 = std::ratio<<%= i %>, <%= n + 1 - i %>>; using r2 = std::ratio<<%= n + 1 - i %>, <%= i %>>; @@ -10,9 +10,9 @@ using r4 = std::ratio_divide; using r5 = units::common_ratio_t; +#endif }; <% end %> -#endif int main() diff --git a/test/metabench/ratio/common_ratio_ratio_type_constexpr.cpp.erb b/test/metabench/ratio/common_ratio_ratio_type_constexpr.cpp.erb new file mode 100644 index 00000000..ec680850 --- /dev/null +++ b/test/metabench/ratio/common_ratio_ratio_type_constexpr.cpp.erb @@ -0,0 +1,20 @@ +#include "ratio_type_constexpr.h" + +<% (1..n).each do |i| %> + struct test<%= i %> { + using r1 = units::ratio<<%= i %>, <%= n + 1 - i %>>; + using r2 = units::ratio<<%= n + 1 - i %>, <%= i %>>; + + using r3 = units::ratio_multiply; + using r4 = units::ratio_divide; + +#if defined(METABENCH) + using r5 = units::common_ratio_t; +#endif + }; +<% end %> + + +int main() +{ +} diff --git a/test/metabench/ratio/common_ratio_std_ratio.cpp.erb b/test/metabench/ratio/common_ratio_std_ratio.cpp.erb new file mode 100644 index 00000000..5da2d0a0 --- /dev/null +++ b/test/metabench/ratio/common_ratio_std_ratio.cpp.erb @@ -0,0 +1,20 @@ +#include "std_ratio.h" + +<% (1..n).each do |i| %> + struct test<%= i %> { + using r1 = std::ratio<<%= i %>, <%= n + 1 - i %>>; + using r2 = std::ratio<<%= n + 1 - i %>, <%= i %>>; + + using r3 = std::ratio_multiply; + using r4 = std::ratio_divide; + +#if defined(METABENCH) + using r5 = units::common_ratio_t; +#endif + }; +<% end %> + + +int main() +{ +} diff --git a/test/metabench/ratio/create_ratio_type_constexpr.cpp.erb b/test/metabench/ratio/create_ratio_type_constexpr.cpp.erb new file mode 100644 index 00000000..80fa9e72 --- /dev/null +++ b/test/metabench/ratio/create_ratio_type_constexpr.cpp.erb @@ -0,0 +1,15 @@ +#include "ratio_type_constexpr.h" + +<% (1..n).each do |i| %> + struct test<%= i %> { +#if defined(METABENCH) + using r1 = units::ratio<<%= i %>, <%= n + 1 - i %>>; + using r2 = units::ratio<<%= n + 1 - i %>, <%= i %>>; +#endif + }; +<% end %> + + +int main() +{ +} diff --git a/test/metabench/ratio/create_std_ratio.cpp.erb b/test/metabench/ratio/create_std_ratio.cpp.erb new file mode 100644 index 00000000..3555aab8 --- /dev/null +++ b/test/metabench/ratio/create_std_ratio.cpp.erb @@ -0,0 +1,15 @@ +#include "std_ratio.h" + +<% (1..n).each do |i| %> + struct test<%= i %> { +#if defined(METABENCH) + using r1 = std::ratio<<%= i %>, <%= n + 1 - i %>>; + using r2 = std::ratio<<%= n + 1 - i %>, <%= i %>>; +#endif + }; +<% end %> + + +int main() +{ +} diff --git a/test/metabench/ratio/multiply_divide_ratio_type_constexpr.cpp.erb b/test/metabench/ratio/multiply_divide_ratio_type_constexpr.cpp.erb new file mode 100644 index 00000000..d7c4d98f --- /dev/null +++ b/test/metabench/ratio/multiply_divide_ratio_type_constexpr.cpp.erb @@ -0,0 +1,18 @@ +#include "ratio_type_constexpr.h" + +<% (1..n).each do |i| %> + struct test<%= i %> { + using r1 = units::ratio<<%= i %>, <%= n + 1 - i %>>; + using r2 = units::ratio<<%= n + 1 - i %>, <%= i %>>; + +#if defined(METABENCH) + using r3 = units::ratio_multiply; + using r4 = units::ratio_divide; +#endif + }; +<% end %> + + +int main() +{ +} diff --git a/test/metabench/ratio/multiply_divide_std_ratio.cpp.erb b/test/metabench/ratio/multiply_divide_std_ratio.cpp.erb new file mode 100644 index 00000000..0216d2ea --- /dev/null +++ b/test/metabench/ratio/multiply_divide_std_ratio.cpp.erb @@ -0,0 +1,18 @@ +#include "std_ratio.h" + +<% (1..n).each do |i| %> + struct test<%= i %> { + using r1 = std::ratio<<%= i %>, <%= n + 1 - i %>>; + using r2 = std::ratio<<%= n + 1 - i %>, <%= i %>>; + +#if defined(METABENCH) + using r3 = std::ratio_multiply; + using r4 = std::ratio_divide; +#endif + }; +<% end %> + + +int main() +{ +}