Ratio metabench tests split to individual operations

This commit is contained in:
Mateusz Pusz
2019-05-19 17:40:05 +02:00
parent 225696135c
commit 7caadfcd0d
10 changed files with 201 additions and 13 deletions

View File

@@ -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)

View File

@@ -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)

View File

@@ -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<r1, r2>;
using r4 = units::ratio_divide<r1, r2>;
using r5 = units::common_ratio_t<r1, r2>;
#endif
};
<% end %>
int main()
{
}

View File

@@ -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<r1, r2>;
using r5 = units::common_ratio_t<r1, r2>;
#endif
};
<% end %>
#endif
int main()

View File

@@ -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<r1, r2>;
using r4 = units::ratio_divide<r1, r2>;
#if defined(METABENCH)
using r5 = units::common_ratio_t<r1, r2>;
#endif
};
<% end %>
int main()
{
}

View File

@@ -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<r1, r2>;
using r4 = std::ratio_divide<r1, r2>;
#if defined(METABENCH)
using r5 = units::common_ratio_t<r1, r2>;
#endif
};
<% end %>
int main()
{
}

View File

@@ -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()
{
}

View File

@@ -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()
{
}

View File

@@ -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<r1, r2>;
using r4 = units::ratio_divide<r1, r2>;
#endif
};
<% end %>
int main()
{
}

View File

@@ -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<r1, r2>;
using r4 = std::ratio_divide<r1, r2>;
#endif
};
<% end %>
int main()
{
}