mirror of
https://github.com/boostorg/math.git
synced 2026-01-19 04:22:09 +00:00
Add first cut at performance tests.
This commit is contained in:
@@ -16,6 +16,10 @@ import ../../../config/checks/config : requires ;
|
||||
using quickbook ;
|
||||
using auto-index ;
|
||||
|
||||
import ../../../predef/check/predef
|
||||
: check require
|
||||
: predef-check predef-require ;
|
||||
|
||||
project
|
||||
: requirements
|
||||
<include>../../include_private
|
||||
@@ -82,19 +86,21 @@ rule all-tests {
|
||||
local result ;
|
||||
for local source in [ glob test*.cpp ]
|
||||
{
|
||||
result += [ run $(source) /boost/regex//boost_regex /boost/system /boost/chrono /boost/filesystem table_helper
|
||||
: : : release <include>../../test [ check-target-builds ../accuracy//has_c99_cmath : <define>TEST_C99 ] ] ;
|
||||
}
|
||||
|
||||
#
|
||||
# Special cases to test different compiler options:
|
||||
#
|
||||
result += [ run test_cbrt.cpp /boost/regex//boost_regex /boost/system /boost/chrono /boost/filesystem table_helper
|
||||
: : : debug <toolset>msvc [ check-target-builds ../accuracy//has_c99_cmath : <define>TEST_C99 : ] : test_cbrt_msvc_debug ] ;
|
||||
: : : debug <define>COMPILER_COMPARISON_TABLES [ predef-require "BOOST_COMP_MSVC" ] : test_cbrt_msvc_debug ] ;
|
||||
result += [ run test_cbrt.cpp /boost/regex//boost_regex /boost/system /boost/chrono /boost/filesystem table_helper
|
||||
: : : release <address-model>32 <toolset>msvc [ check-target-builds ../accuracy//has_c99_cmath : <define>TEST_C99 : ] : test_cbrt_msvc_release_32 ] ;
|
||||
: : : release <define>COMPILER_COMPARISON_TABLES <address-model>32 [ predef-require "BOOST_COMP_MSVC" ] <cxxflags>-Ox : test_cbrt_msvc_release_32 ] ;
|
||||
result += [ run test_cbrt.cpp /boost/regex//boost_regex /boost/system /boost/chrono /boost/filesystem table_helper
|
||||
: : : release <address-model>64 <toolset>msvc <cxxflags>-arch:SSE2 [ check-target-builds ../accuracy//has_c99_cmath : <define>TEST_C99 : ] : test_cbrt_msvc_release_64 ] ;
|
||||
: : : release <define>COMPILER_COMPARISON_TABLES <address-model>64 [ predef-require "BOOST_COMP_MSVC" ] <cxxflags>-Ox : test_cbrt_msvc_release_64 ] ;
|
||||
result += [ run test_cbrt.cpp /boost/regex//boost_regex /boost/system /boost/chrono /boost/filesystem table_helper
|
||||
: : : release <address-model>64 <cxxflags>-arch:AVX <toolset>msvc [ check-target-builds ../accuracy//has_c99_cmath : <define>TEST_C99 : ] : test_cbrt_msvc_release_64_avx ] ;
|
||||
: : : release <define>COMPILER_COMPARISON_TABLES [ predef-require "__ICL +0 > 1100" ] <cxxflags>-Ox : test_cbrt_intel_release ] ;
|
||||
|
||||
return $(result) ;
|
||||
}
|
||||
|
||||
@@ -1,34 +1,51 @@
|
||||
[/Cell Content:]
|
||||
[template cl_arch_ia32_Ox_x64_build_Microsoft_Visual_C_version_12_0Win32[]62ns]
|
||||
[template boost_math_cbrtcl_arch_ia32_Ox_x64_build_Microsoft_Visual_C_version_12_0Win32[]45ns]
|
||||
[template cl_arch_sse2_Ox_x86_build_Microsoft_Visual_C_version_12_0Win32[]68ns]
|
||||
[template boost_math_cbrtcl_arch_sse2_Ox_x86_build_Microsoft_Visual_C_version_12_0Win32[]64ns]
|
||||
[template cl_Od_x86_build_Microsoft_Visual_C_version_12_0Win32[]201ns]
|
||||
[template boost_math_cbrtcl_Od_x86_build_Microsoft_Visual_C_version_12_0Win32[]262ns]
|
||||
|
||||
|
||||
|
||||
[/tables:]
|
||||
[template table_Compiler_Option_Comparison_on_Win32[]
|
||||
[table:table_Compiler_Option_Comparison_on_Win32 Compiler Option Comparison on Win32
|
||||
[[Function][icl /arch:ia32 /Ox (x86 build)][cl /Ox (x64 build)][cl /arch:sse2 /Ox (x86 build)][cl /Od (x86 build)]]
|
||||
[[boost::math::cbrt][[role green 37ns]][[role blue 60ns]][[role blue 63ns]][[role red 277ns]]]
|
||||
]
|
||||
]
|
||||
|
||||
[template table_cbrt[]
|
||||
[table:table_cbrt Performance comparison for cbrt
|
||||
[[Function][cl /Od (x86 build)][cl /arch:sse2 /Ox (x86 build)][cl /arch:ia32 /Ox (x64 build)]]
|
||||
[[boost::math::cbrt][[role green 86ns]][[role green 2ns]][[role green 32ns]]]
|
||||
[[::cbrt][[role green 86ns]][[role green 2ns]][[role green 32ns]]]
|
||||
|
||||
[template table_Library_Comparison_on_Win32[]
|
||||
[table:table_Library_Comparison_on_Win32 Library Comparison on Win32
|
||||
[[Function][Boost][math.h]]
|
||||
[[cbrt[br](85/85 tests selected)][[role green 64ns]][[role green 69ns]]]
|
||||
[[erf[br](950/950 tests selected)][[role green 14ns]][[role blue 26ns]]]
|
||||
[[erfc[br](950/950 tests selected)][[role green 20ns]][[role red 93ns]]]
|
||||
[[expm1[br](80/80 tests selected)][[role green 12ns]][[role green 13ns]]]
|
||||
[[cyl_bessel_j (integer order)[br](268/268 tests selected)][[role green 121ns]][[role red 260ns]]]
|
||||
[[lgamma[br](400/400 tests selected)][[role green 91ns]][[role blue 148ns]]]
|
||||
[[log1p[br](80/80 tests selected)][[role green 12ns]][[role blue 19ns]]]
|
||||
[[tgamma[br](400/400 tests selected)][[role green 89ns]][[role red 975ns]]]
|
||||
[[cyl_neumann (integer order)[br](428/428 tests selected)][[role blue 327ns]][[role green 169ns]]]
|
||||
]
|
||||
]
|
||||
|
||||
|
||||
[/sections:]
|
||||
[template section_Compiler_Option_Comparison_on_Win32[]
|
||||
[section:section_Compiler_Option_Comparison_on_Win32 Compiler Option Comparison on Win32]
|
||||
[table_Compiler_Option_Comparison_on_Win32]
|
||||
[endsect]
|
||||
]
|
||||
|
||||
[template section_cbrt[]
|
||||
[section:section_cbrt cbrt]
|
||||
[table_cbrt]
|
||||
|
||||
[template section_Library_Comparison_on_Win32[]
|
||||
[section:section_Library_Comparison_on_Win32 Library Comparison on Win32]
|
||||
[table_Library_Comparison_on_Win32]
|
||||
[endsect]
|
||||
]
|
||||
|
||||
[template all_sections[]
|
||||
[section_cbrt]
|
||||
[section_Compiler_Option_Comparison_on_Win32]
|
||||
[section_Library_Comparison_on_Win32]
|
||||
]
|
||||
|
||||
[template all_tables[]
|
||||
[table_cbrt]
|
||||
[table_Compiler_Option_Comparison_on_Win32]
|
||||
[table_Library_Comparison_on_Win32]
|
||||
]
|
||||
|
||||
@@ -33,20 +33,27 @@
|
||||
</div>
|
||||
<div class="toc">
|
||||
<p><b>Table of Contents</b></p>
|
||||
<dl><dt><span class="section"><a href="index.html#special_function_error_rates_rep.section_cbrt">cbrt</a></span></dt></dl>
|
||||
<dl>
|
||||
<dt><span class="section"><a href="index.html#special_function_error_rates_rep.section_Compiler_Option_Comparison_on_Win32">Compiler
|
||||
Option Comparison on Win32</a></span></dt>
|
||||
<dt><span class="section"><a href="index.html#special_function_error_rates_rep.section_Library_Comparison_on_Win32">Library
|
||||
Comparison on Win32</a></span></dt>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
|
||||
<a name="special_function_error_rates_rep.section_cbrt"></a><a class="link" href="index.html#special_function_error_rates_rep.section_cbrt" title="cbrt">cbrt</a>
|
||||
<a name="special_function_error_rates_rep.section_Compiler_Option_Comparison_on_Win32"></a><a class="link" href="index.html#special_function_error_rates_rep.section_Compiler_Option_Comparison_on_Win32" title="Compiler Option Comparison on Win32">Compiler
|
||||
Option Comparison on Win32</a>
|
||||
</h2></div></div></div>
|
||||
<div class="table">
|
||||
<a name="special_function_error_rates_rep.section_cbrt.table_cbrt"></a><p class="title"><b>Table 1. Performance comparison for cbrt</b></p>
|
||||
<div class="table-contents"><table class="table" summary="Performance comparison for cbrt">
|
||||
<a name="special_function_error_rates_rep.section_Compiler_Option_Comparison_on_Win32.table_Compiler_Option_Comparison_on_Win32"></a><p class="title"><b>Table 1. Compiler Option Comparison on Win32</b></p>
|
||||
<div class="table-contents"><table class="table" summary="Compiler Option Comparison on Win32">
|
||||
<colgroup>
|
||||
<col>
|
||||
<col>
|
||||
<col>
|
||||
<col>
|
||||
<col>
|
||||
</colgroup>
|
||||
<thead><tr>
|
||||
<th>
|
||||
@@ -56,7 +63,12 @@
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
cl /Od (x86 build)
|
||||
icl /arch:ia32 /Ox (x86 build)
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
cl /Ox (x64 build)
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
@@ -66,12 +78,11 @@
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
cl /arch:ia32 /Ox (x64 build)
|
||||
cl /Od (x86 build)
|
||||
</p>
|
||||
</th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<tbody><tr>
|
||||
<td>
|
||||
<p>
|
||||
boost::math::cbrt
|
||||
@@ -79,39 +90,210 @@
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="green">86ns</span>
|
||||
<span class="green">37ns</span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="green">2ns</span>
|
||||
<span class="blue">60ns</span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="green">32ns</span>
|
||||
<span class="blue">63ns</span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="red">277ns</span>
|
||||
</p>
|
||||
</td>
|
||||
</tr></tbody>
|
||||
</table></div>
|
||||
</div>
|
||||
<br class="table-break">
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
|
||||
<a name="special_function_error_rates_rep.section_Library_Comparison_on_Win32"></a><a class="link" href="index.html#special_function_error_rates_rep.section_Library_Comparison_on_Win32" title="Library Comparison on Win32">Library
|
||||
Comparison on Win32</a>
|
||||
</h2></div></div></div>
|
||||
<div class="table">
|
||||
<a name="special_function_error_rates_rep.section_Library_Comparison_on_Win32.table_Library_Comparison_on_Win32"></a><p class="title"><b>Table 2. Library Comparison on Win32</b></p>
|
||||
<div class="table-contents"><table class="table" summary="Library Comparison on Win32">
|
||||
<colgroup>
|
||||
<col>
|
||||
<col>
|
||||
<col>
|
||||
</colgroup>
|
||||
<thead><tr>
|
||||
<th>
|
||||
<p>
|
||||
Function
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
Boost
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
math.h
|
||||
</p>
|
||||
</th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
cbrt<br> (85/85 tests selected)
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="green">64ns</span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="green">69ns</span>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
::cbrt
|
||||
erf<br> (950/950 tests selected)
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="green">86ns</span>
|
||||
<span class="green">14ns</span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="green">2ns</span>
|
||||
<span class="blue">26ns</span>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
erfc<br> (950/950 tests selected)
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="green">32ns</span>
|
||||
<span class="green">20ns</span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="red">93ns</span>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
expm1<br> (80/80 tests selected)
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="green">12ns</span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="green">13ns</span>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
cyl_bessel_j (integer order)<br> (268/268 tests selected)
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="green">121ns</span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="red">260ns</span>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
lgamma<br> (400/400 tests selected)
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="green">91ns</span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="blue">148ns</span>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
log1p<br> (80/80 tests selected)
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="green">12ns</span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="blue">19ns</span>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
tgamma<br> (400/400 tests selected)
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="green">89ns</span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="red">975ns</span>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
cyl_neumann (integer order)<br> (428/428 tests selected)
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="blue">327ns</span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="green">169ns</span>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -122,7 +304,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"><p><small>Last revised: July 09, 2015 at 18:35:13 GMT</small></p></td>
|
||||
<td align="left"><p><small>Last revised: July 13, 2015 at 07:59:35 GMT</small></p></td>
|
||||
<td align="right"><div class="copyright-footer"></div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
|
||||
@@ -98,59 +98,13 @@ std::string save_table(std::vector<std::vector<std::string> >& table)
|
||||
{
|
||||
std::string result;
|
||||
|
||||
static const boost::regex value_e("\\d+");
|
||||
|
||||
std::vector<boost::uintmax_t> best_values(table[0].size(), (std::numeric_limits<boost::uintmax_t>::max)());
|
||||
|
||||
for(unsigned i = 1; i < table[0].size(); ++i)
|
||||
{
|
||||
for(unsigned k = 1; k < table.size(); ++k)
|
||||
{
|
||||
boost::smatch what;
|
||||
if(regex_search(table[k][i], what, value_e))
|
||||
{
|
||||
boost::uintmax_t val = boost::lexical_cast<boost::uintmax_t>(what.str());
|
||||
if(val < best_values[i])
|
||||
best_values[i] = val;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(std::vector<std::vector<std::string> >::const_iterator i = table.begin(), j = table.end(); i != j; ++i)
|
||||
{
|
||||
result += "[";
|
||||
for(std::vector<std::string>::const_iterator k = i->begin(), l = i->end(); k != l; ++k)
|
||||
{
|
||||
result += "[";
|
||||
if((i == table.begin()) || (k == i->begin()))
|
||||
{
|
||||
result += *k;
|
||||
}
|
||||
else
|
||||
{
|
||||
boost::smatch what;
|
||||
if(regex_search(*k, what, value_e))
|
||||
{
|
||||
boost::uintmax_t val = boost::lexical_cast<boost::uintmax_t>(what.str());
|
||||
bool have_role = false;
|
||||
if(val < 1.2 * best_values[k - i->begin()])
|
||||
{
|
||||
have_role = true;
|
||||
result += "[role green ";
|
||||
}
|
||||
else if(val > 2 * best_values[k - i->begin()])
|
||||
{
|
||||
have_role = true;
|
||||
result += "[role red ";
|
||||
}
|
||||
result += boost::lexical_cast<std::string>(val);
|
||||
result += "ns";
|
||||
if(have_role)
|
||||
result += "]";
|
||||
}
|
||||
else
|
||||
result += *k;
|
||||
}
|
||||
result += *k;
|
||||
result += "]";
|
||||
}
|
||||
result += "]\n";
|
||||
@@ -201,7 +155,27 @@ void add_to_all_sections(const std::string& id, std::string list_name)
|
||||
}
|
||||
}
|
||||
|
||||
void add_cell(const std::string& cell_name, const std::string& table_name, const std::string& row_name, const std::string& column_heading)
|
||||
std::string get_colour(boost::uintmax_t val, boost::uintmax_t best)
|
||||
{
|
||||
if(val <= best * 1.2)
|
||||
return "green";
|
||||
if(val > best * 2)
|
||||
return "red";
|
||||
return "blue";
|
||||
}
|
||||
|
||||
boost::intmax_t get_value_from_cell(const std::string& cell)
|
||||
{
|
||||
static const boost::regex time_e("\\[role[^\\d]+(\\d+)ns\\]");
|
||||
boost::smatch what;
|
||||
if(regex_search(cell, what, time_e))
|
||||
{
|
||||
return boost::lexical_cast<boost::uintmax_t>(what.str(1));
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void add_cell(boost::intmax_t val, const std::string& table_name, const std::string& row_name, const std::string& column_heading)
|
||||
{
|
||||
//
|
||||
// Load the table, add our data, and re-write:
|
||||
@@ -266,27 +240,44 @@ void add_cell(const std::string& cell_name, const std::string& table_name, const
|
||||
row_id = table_data.size() - 1;
|
||||
}
|
||||
//
|
||||
// Update the entry:
|
||||
// Find the best result in this row:
|
||||
//
|
||||
std::string& s = table_data[row_id][column_id];
|
||||
if(s.empty())
|
||||
boost::uintmax_t best = (std::numeric_limits<boost::uintmax_t>::max)();
|
||||
std::vector<boost::intmax_t> values;
|
||||
for(unsigned i = 1; i < table_data[row_id].size(); ++i)
|
||||
{
|
||||
std::cout << "Adding " << cell_name << " to empty cell.";
|
||||
s = "[" + cell_name + "]";
|
||||
}
|
||||
else
|
||||
{
|
||||
if(cell_name.find("_boost_") != std::string::npos)
|
||||
if(i == column_id)
|
||||
{
|
||||
std::cout << "Adding " << cell_name << " to start of cell.";
|
||||
s.insert(0, "[" + cell_name + "][br][br]");
|
||||
if(val < best)
|
||||
best = val;
|
||||
values.push_back(val);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Adding " << cell_name << " to end of cell.";
|
||||
if((s.find("_boost_") != std::string::npos) && (s.find("[br]") == std::string::npos))
|
||||
s += "[br]"; // extra break if we're adding directly after the boost results.
|
||||
s += "[br][" + cell_name + "]";
|
||||
std::cout << "Existing cell value was " << table_data[row_id][i] << std::endl;
|
||||
boost::uintmax_t cell_val = get_value_from_cell(table_data[row_id][i]);
|
||||
std::cout << "Extracted value: " << cell_val << std::endl;
|
||||
if(cell_val < best)
|
||||
best = cell_val;
|
||||
values.push_back(cell_val);
|
||||
}
|
||||
}
|
||||
//
|
||||
// Update the row:
|
||||
//
|
||||
for(unsigned i = 1; i < table_data[row_id].size(); ++i)
|
||||
{
|
||||
std::string& s = table_data[row_id][i];
|
||||
s = "[role ";
|
||||
if(values[i - 1] < 0)
|
||||
{
|
||||
s += "grey -]";
|
||||
}
|
||||
else
|
||||
{
|
||||
s += get_colour(values[i - 1], best);
|
||||
s += " ";
|
||||
s += boost::lexical_cast<std::string>(values[i - 1]) + "ns]";
|
||||
}
|
||||
}
|
||||
//
|
||||
@@ -301,16 +292,16 @@ void add_cell(const std::string& cell_name, const std::string& table_name, const
|
||||
//
|
||||
std::string new_table = "\n[template " + table_id;
|
||||
new_table += "[]\n[table:" + table_id;
|
||||
new_table += " Performance comparison for ";
|
||||
new_table += " ";
|
||||
new_table += table_name;
|
||||
new_table += "\n[[Function][";
|
||||
new_table += column_heading;
|
||||
new_table += "]]\n";
|
||||
new_table += "[[";
|
||||
new_table += row_name;
|
||||
new_table += "][[";
|
||||
new_table += cell_name;
|
||||
new_table += "]]]\n]\n]\n";
|
||||
new_table += "][[role blue ";
|
||||
new_table += boost::lexical_cast<std::string>(val);
|
||||
new_table += "ns]]]\n]\n]\n";
|
||||
|
||||
std::string::size_type pos = content.find("[/tables:]");
|
||||
if(pos != std::string::npos)
|
||||
@@ -338,70 +329,42 @@ void add_cell(const std::string& cell_name, const std::string& table_name, const
|
||||
}
|
||||
}
|
||||
|
||||
void set_result(const std::string& cell_name, const std::string& cell_content, const std::string& table_name, const std::string& row_name, const std::string& column_name)
|
||||
void report_execution_time(double t, std::string table, std::string row, std::string heading)
|
||||
{
|
||||
loader.instantiate();
|
||||
const boost::regex e("\\[template\\s+" + cell_name +
|
||||
"\\[\\]([^\\n]*)\\]$");
|
||||
|
||||
boost::smatch what;
|
||||
if(regex_search(content, what, e))
|
||||
{
|
||||
content.replace(what.position(1), what.length(1), cell_content);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Need to add new content:
|
||||
std::string::size_type pos = content.find("[/Cell Content:]");
|
||||
std::string t = "\n[template " + cell_name + "[] " + cell_content + "]";
|
||||
if(pos != std::string::npos)
|
||||
content.insert(pos + 16, t);
|
||||
else
|
||||
{
|
||||
content.insert(0, t);
|
||||
content.insert(0, "[/Cell Content:]");
|
||||
}
|
||||
}
|
||||
//
|
||||
// Check to verify that our content is actually used somewhere,
|
||||
// if not we need to create a place for it:
|
||||
//
|
||||
if(content.find("[" + cell_name + "]") == std::string::npos)
|
||||
add_cell(cell_name, table_name, row_name, column_name);
|
||||
}
|
||||
|
||||
|
||||
void report_execution_time_multi_compilation(double t, std::string function_group, std::string function, std::string compilation)
|
||||
{
|
||||
std::string cell_name = sanitize_string(function) + sanitize_string(compilation) + sanitize_string(BOOST_COMPILER) + sanitize_string(BOOST_PLATFORM);
|
||||
std::string cell_content = boost::lexical_cast<std::string>(static_cast<boost::uintmax_t>(t / 1e-9));
|
||||
cell_content += "ns";
|
||||
std::string table_name = function_group;
|
||||
std::string row_name = function;
|
||||
std::string column_name = compilation;
|
||||
set_result(cell_name, cell_content, table_name, row_name, column_name);
|
||||
add_cell(static_cast<boost::uintmax_t>(t / 1e-9), table, row, heading);
|
||||
}
|
||||
|
||||
std::string get_compiler_options_name()
|
||||
{
|
||||
#if defined(BOOST_MSVC)
|
||||
#if defined(BOOST_MSVC) || defined(__ICL)
|
||||
std::string result;
|
||||
#ifdef _DEBUG
|
||||
result = "cl /Od";
|
||||
#elif defined(__AVX2__)
|
||||
result = "cl /arch:AVX2 /Ox";
|
||||
#elif defined(__AVX__)
|
||||
result = "cl /arch:AVX /Ox";
|
||||
#elif _M_IX86_FP == 2
|
||||
result = "cl /arch:sse2 /Ox";
|
||||
#ifdef BOOST_MSVC
|
||||
result = "cl ";
|
||||
#else
|
||||
result = "cl /arch:ia32 /Ox";
|
||||
result = "icl ";
|
||||
#endif
|
||||
#ifdef _M_AMD64
|
||||
#ifdef __AVX__
|
||||
result += "/arch:AVX /Ox";
|
||||
#else
|
||||
result += "/Ox";
|
||||
#endif
|
||||
result += " (x64 build)";
|
||||
#else
|
||||
#ifdef _DEBUG
|
||||
result += "/Od";
|
||||
#elif defined(__AVX2__)
|
||||
result += "/arch:AVX2 /Ox";
|
||||
#elif defined(__AVX__)
|
||||
result += "/arch:AVX /Ox";
|
||||
#elif _M_IX86_FP == 2
|
||||
result += "/arch:sse2 /Ox";
|
||||
#else
|
||||
result += "/arch:ia32 /Ox";
|
||||
#endif
|
||||
result += " (x86 build)";
|
||||
#endif
|
||||
std::cout << "Compiler options are found as: " << result << std::endl;
|
||||
return result;
|
||||
#else
|
||||
return "Unknown";
|
||||
|
||||
@@ -17,7 +17,7 @@ std::string save_table(std::vector<std::vector<std::string> >& table);
|
||||
void add_to_all_sections(const std::string& id, std::string list_name = "all_sections");
|
||||
void add_cell(const std::string& cell_name, const std::string& table_name, const std::string& row_name, const std::string& column_heading);
|
||||
void set_result(const std::string& cell_name, const std::string& cell_content, const std::string& table_name, const std::string& row_name, const std::string& column_name);
|
||||
void report_execution_time_multi_compilation(double t, std::string function_group, std::string function, std::string compilation);
|
||||
void report_execution_time(double t, std::string table, std::string row, std::string heading);
|
||||
std::string get_compiler_options_name();
|
||||
|
||||
#endif // TABLE_HELPER_HPP
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <boost/math/special_functions/cbrt.hpp>
|
||||
#include <boost/array.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include "../../test/table_type.hpp"
|
||||
#include "table_helper.hpp"
|
||||
#include "performance.hpp"
|
||||
@@ -22,20 +23,41 @@ int main()
|
||||
|
||||
add_data(cbrt_data);
|
||||
|
||||
unsigned data_total = data.size();
|
||||
|
||||
screen_data([](const std::vector<double>& v){ return boost::math::cbrt(v[1]); }, [](const std::vector<double>& v){ return v[0]; });
|
||||
|
||||
#ifdef TEST_C99
|
||||
#if defined(TEST_C99) && !defined(COMPILER_COMPARISON_TABLES)
|
||||
screen_data([](const std::vector<double>& v){ return ::cbrt(v[1]); }, [](const std::vector<double>& v){ return v[0]; });
|
||||
#endif
|
||||
|
||||
unsigned data_used = data.size();
|
||||
std::string function = "cbrt[br](" + boost::lexical_cast<std::string>(data_used) + "/" + boost::lexical_cast<std::string>(data_total) + " tests selected)";
|
||||
|
||||
double time = exec_timed_test([](const std::vector<double>& v){ return boost::math::cbrt(v[1]); });
|
||||
report_execution_time_multi_compilation(time, "cbrt", "boost::math::cbrt", get_compiler_options_name());
|
||||
std::cout << time << std::endl;
|
||||
#ifdef TEST_C99
|
||||
#if defined(COMPILER_COMPARISON_TABLES)
|
||||
report_execution_time(time, std::string("Compiler Option Comparison on ") + BOOST_PLATFORM, "boost::math::cbrt", get_compiler_options_name());
|
||||
#else
|
||||
report_execution_time(time, std::string("Library Comparison on ") + BOOST_PLATFORM, function, "Boost");
|
||||
#endif
|
||||
//
|
||||
// Boost again, but with promotion to long double turned off:
|
||||
//
|
||||
#if !defined(COMPILER_COMPARISON_TABLES)
|
||||
if(sizeof(long double) != sizeof(double))
|
||||
{
|
||||
double time = exec_timed_test([](const std::vector<double>& v){ return boost::math::cbrt(v[1], boost::math::policies::make_policy(boost::math::policies::promote_double<false>())); });
|
||||
std::cout << time << std::endl;
|
||||
report_execution_time(time, std::string("Library Comparison on ") + BOOST_PLATFORM, function, "Boost[br](no internal promotion to long double)");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(TEST_C99) && !defined(COMPILER_COMPARISON_TABLES)
|
||||
time = exec_timed_test([](const std::vector<double>& v){ return ::cbrt(v[1]); });
|
||||
std::cout << time << std::endl;
|
||||
report_execution_time_multi_compilation(time, "cbrt", "::cbrt", get_compiler_options_name());
|
||||
report_execution_time(time, std::string("Library Comparison on ") + BOOST_PLATFORM, function, "math.h");
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
67
reporting/performance/test_erf.cpp
Normal file
67
reporting/performance/test_erf.cpp
Normal file
@@ -0,0 +1,67 @@
|
||||
// Copyright John Maddock 2015.
|
||||
// Use, modification and distribution are subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning (disable : 4224)
|
||||
#endif
|
||||
|
||||
#include <boost/math/special_functions/erf.hpp>
|
||||
#include <boost/array.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include "../../test/table_type.hpp"
|
||||
#include "table_helper.hpp"
|
||||
#include "performance.hpp"
|
||||
#include <iostream>
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef double T;
|
||||
#define SC_(x) static_cast<double>(x)
|
||||
# include "erf_small_data.ipp"
|
||||
# include "erf_data.ipp"
|
||||
# include "erf_large_data.ipp"
|
||||
|
||||
add_data(erf_small_data);
|
||||
add_data(erf_data);
|
||||
add_data(erf_large_data);
|
||||
|
||||
unsigned data_total = data.size();
|
||||
|
||||
screen_data([](const std::vector<double>& v){ return boost::math::erf(v[0]); }, [](const std::vector<double>& v){ return v[1]; });
|
||||
|
||||
|
||||
#if defined(TEST_C99) && !defined(COMPILER_COMPARISON_TABLES)
|
||||
screen_data([](const std::vector<double>& v){ return ::erf(v[0]); }, [](const std::vector<double>& v){ return v[1]; });
|
||||
#endif
|
||||
|
||||
unsigned data_used = data.size();
|
||||
std::string function = "erf[br](" + boost::lexical_cast<std::string>(data_used) + "/" + boost::lexical_cast<std::string>(data_total) + " tests selected)";
|
||||
|
||||
double time = exec_timed_test([](const std::vector<double>& v){ return boost::math::erf(v[0]); });
|
||||
std::cout << time << std::endl;
|
||||
report_execution_time(time, std::string("Library Comparison on ") + BOOST_PLATFORM, function, "Boost");
|
||||
//
|
||||
// Boost again, but with promotion to long double turned off:
|
||||
//
|
||||
#if !defined(COMPILER_COMPARISON_TABLES)
|
||||
if(sizeof(long double) != sizeof(double))
|
||||
{
|
||||
double time = exec_timed_test([](const std::vector<double>& v){ return boost::math::erf(v[0], boost::math::policies::make_policy(boost::math::policies::promote_double<false>())); });
|
||||
std::cout << time << std::endl;
|
||||
report_execution_time(time, std::string("Library Comparison on ") + BOOST_PLATFORM, function, "Boost[br](no internal promotion to long double)");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(TEST_C99) && !defined(COMPILER_COMPARISON_TABLES)
|
||||
time = exec_timed_test([](const std::vector<double>& v){ return ::erf(v[0]); });
|
||||
std::cout << time << std::endl;
|
||||
report_execution_time(time, std::string("Library Comparison on ") + BOOST_PLATFORM, function, "math.h");
|
||||
#endif
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
67
reporting/performance/test_erfc.cpp
Normal file
67
reporting/performance/test_erfc.cpp
Normal file
@@ -0,0 +1,67 @@
|
||||
// Copyright John Maddock 2015.
|
||||
// Use, modification and distribution are subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning (disable : 4224)
|
||||
#endif
|
||||
|
||||
#include <boost/math/special_functions/erf.hpp>
|
||||
#include <boost/array.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include "../../test/table_type.hpp"
|
||||
#include "table_helper.hpp"
|
||||
#include "performance.hpp"
|
||||
#include <iostream>
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef double T;
|
||||
#define SC_(x) static_cast<double>(x)
|
||||
# include "erf_small_data.ipp"
|
||||
# include "erf_data.ipp"
|
||||
# include "erf_large_data.ipp"
|
||||
|
||||
add_data(erf_small_data);
|
||||
add_data(erf_data);
|
||||
add_data(erf_large_data);
|
||||
|
||||
unsigned data_total = data.size();
|
||||
|
||||
screen_data([](const std::vector<double>& v){ return boost::math::erfc(v[0]); }, [](const std::vector<double>& v){ return v[2]; });
|
||||
|
||||
|
||||
#if defined(TEST_C99) && !defined(COMPILER_COMPARISON_TABLES)
|
||||
screen_data([](const std::vector<double>& v){ return ::erfc(v[0]); }, [](const std::vector<double>& v){ return v[2]; });
|
||||
#endif
|
||||
|
||||
unsigned data_used = data.size();
|
||||
std::string function = "erfc[br](" + boost::lexical_cast<std::string>(data_used) + "/" + boost::lexical_cast<std::string>(data_total) + " tests selected)";
|
||||
|
||||
double time = exec_timed_test([](const std::vector<double>& v){ return boost::math::erfc(v[0]); });
|
||||
std::cout << time << std::endl;
|
||||
report_execution_time(time, std::string("Library Comparison on ") + BOOST_PLATFORM, function, "Boost");
|
||||
//
|
||||
// Boost again, but with promotion to long double turned off:
|
||||
//
|
||||
#if !defined(COMPILER_COMPARISON_TABLES)
|
||||
if(sizeof(long double) != sizeof(double))
|
||||
{
|
||||
double time = exec_timed_test([](const std::vector<double>& v){ return boost::math::erfc(v[0], boost::math::policies::make_policy(boost::math::policies::promote_double<false>())); });
|
||||
std::cout << time << std::endl;
|
||||
report_execution_time(time, std::string("Library Comparison on ") + BOOST_PLATFORM, function, "Boost[br](no internal promotion to long double)");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(TEST_C99) && !defined(COMPILER_COMPARISON_TABLES)
|
||||
time = exec_timed_test([](const std::vector<double>& v){ return ::erfc(v[0]); });
|
||||
std::cout << time << std::endl;
|
||||
report_execution_time(time, std::string("Library Comparison on ") + BOOST_PLATFORM, function, "math.h");
|
||||
#endif
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
63
reporting/performance/test_expm1.cpp
Normal file
63
reporting/performance/test_expm1.cpp
Normal file
@@ -0,0 +1,63 @@
|
||||
// Copyright John Maddock 2015.
|
||||
// Use, modification and distribution are subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning (disable : 4224)
|
||||
#endif
|
||||
|
||||
#include <boost/math/special_functions/expm1.hpp>
|
||||
#include <boost/array.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include "../../test/table_type.hpp"
|
||||
#include "table_helper.hpp"
|
||||
#include "performance.hpp"
|
||||
#include <iostream>
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef double T;
|
||||
#define SC_(x) static_cast<double>(x)
|
||||
# include "../../test/log1p_expm1_data.ipp"
|
||||
|
||||
add_data(log1p_expm1_data);
|
||||
|
||||
unsigned data_total = data.size();
|
||||
|
||||
screen_data([](const std::vector<double>& v){ return boost::math::expm1(v[0]); }, [](const std::vector<double>& v){ return v[2]; });
|
||||
|
||||
|
||||
#if defined(TEST_C99) && !defined(COMPILER_COMPARISON_TABLES)
|
||||
screen_data([](const std::vector<double>& v){ return ::expm1(v[0]); }, [](const std::vector<double>& v){ return v[2]; });
|
||||
#endif
|
||||
|
||||
unsigned data_used = data.size();
|
||||
std::string function = "expm1[br](" + boost::lexical_cast<std::string>(data_used) + "/" + boost::lexical_cast<std::string>(data_total) + " tests selected)";
|
||||
|
||||
double time = exec_timed_test([](const std::vector<double>& v){ return boost::math::expm1(v[0]); });
|
||||
std::cout << time << std::endl;
|
||||
report_execution_time(time, std::string("Library Comparison on ") + BOOST_PLATFORM, function, "Boost");
|
||||
//
|
||||
// Boost again, but with promotion to long double turned off:
|
||||
//
|
||||
#if !defined(COMPILER_COMPARISON_TABLES)
|
||||
if(sizeof(long double) != sizeof(double))
|
||||
{
|
||||
double time = exec_timed_test([](const std::vector<double>& v){ return boost::math::expm1(v[0], boost::math::policies::make_policy(boost::math::policies::promote_double<false>())); });
|
||||
std::cout << time << std::endl;
|
||||
report_execution_time(time, std::string("Library Comparison on ") + BOOST_PLATFORM, function, "Boost[br](no internal promotion to long double)");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(TEST_C99) && !defined(COMPILER_COMPARISON_TABLES)
|
||||
time = exec_timed_test([](const std::vector<double>& v){ return ::expm1(v[0]); });
|
||||
std::cout << time << std::endl;
|
||||
report_execution_time(time, std::string("Library Comparison on ") + BOOST_PLATFORM, function, "math.h");
|
||||
#endif
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
133
reporting/performance/test_jn.cpp
Normal file
133
reporting/performance/test_jn.cpp
Normal file
@@ -0,0 +1,133 @@
|
||||
// Copyright John Maddock 2015.
|
||||
// Use, modification and distribution are subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning (disable : 4224)
|
||||
#endif
|
||||
|
||||
#include <boost/math/special_functions/bessel.hpp>
|
||||
#include <boost/array.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include "../../test/table_type.hpp"
|
||||
#include "table_helper.hpp"
|
||||
#include "performance.hpp"
|
||||
#include <iostream>
|
||||
|
||||
typedef double T;
|
||||
#define SC_(x) static_cast<double>(x)
|
||||
static const boost::array<boost::array<typename table_type<T>::type, 3>, 8> j0_data = { {
|
||||
{ { SC_(0.0), SC_(0.0), SC_(1.0) } },
|
||||
{ { SC_(0.0), SC_(1.0), SC_(0.7651976865579665514497175261026632209093) } },
|
||||
{ { SC_(0.0), SC_(-2.0), SC_(0.2238907791412356680518274546499486258252) } },
|
||||
{ { SC_(0.0), SC_(4.0), SC_(-0.3971498098638473722865907684516980419756) } },
|
||||
{ { SC_(0.0), SC_(-8.0), SC_(0.1716508071375539060908694078519720010684) } },
|
||||
{ { SC_(0.0), SC_(1e-05), SC_(0.999999999975000000000156249999999565972) } },
|
||||
{ { SC_(0.0), SC_(1e-10), SC_(0.999999999999999999997500000000000000000) } },
|
||||
{ { SC_(0.0), SC_(-1e+01), SC_(-0.2459357644513483351977608624853287538296) } },
|
||||
} };
|
||||
static const boost::array<boost::array<T, 3>, 6> j0_tricky = { {
|
||||
// Big numbers make the accuracy of std::sin the limiting factor:
|
||||
{ { SC_(0.0), SC_(1e+03), SC_(0.02478668615242017456133073111569370878617) } },
|
||||
{ { SC_(0.0), SC_(1e+05), SC_(-0.001719201116235972192570601477073201747532) } },
|
||||
// test at the roots:
|
||||
{ { SC_(0.0), T(2521642.0) / (1024 * 1024), SC_(1.80208819970046790002973759410972422387259992955354630042138e-7) } },
|
||||
{ { SC_(0.0), T(5788221.0) / (1024 * 1024), SC_(-1.37774249380686777043369399806210229535671843632174587432454e-7) } },
|
||||
{ { SC_(0.0), T(9074091.0) / (1024 * 1024), SC_(1.03553057441100845081018471279571355857520645127532785991335e-7) } },
|
||||
{ { SC_(0.0), T(12364320.0) / (1024 * 1024), SC_(-3.53017140778223781420794006033810387155048392363051866610931e-9) } }
|
||||
} };
|
||||
|
||||
static const boost::array<boost::array<typename table_type<T>::type, 3>, 8> j1_data = { {
|
||||
{ { SC_(1.0), SC_(0.0), SC_(0.0) } },
|
||||
{ { SC_(1.0), SC_(1.0), SC_(0.4400505857449335159596822037189149131274) } },
|
||||
{ { SC_(1.0), SC_(-2.0), SC_(-0.5767248077568733872024482422691370869203) } },
|
||||
{ { SC_(1.0), SC_(4.0), SC_(-6.604332802354913614318542080327502872742e-02) } },
|
||||
{ { SC_(1.0), SC_(-8.0), SC_(-0.2346363468539146243812766515904546115488) } },
|
||||
{ { SC_(1.0), SC_(1e-05), SC_(4.999999999937500000000260416666666124132e-06) } },
|
||||
{ { SC_(1.0), SC_(1e-10), SC_(4.999999999999999999993750000000000000000e-11) } },
|
||||
{ { SC_(1.0), SC_(-1e+01), SC_(-4.347274616886143666974876802585928830627e-02) } },
|
||||
} };
|
||||
static const boost::array<boost::array<T, 3>, 5> j1_tricky = { {
|
||||
// Big numbers make the accuracy of std::sin the limiting factor:
|
||||
{ { SC_(1.0), SC_(1e+03), SC_(4.728311907089523917576071901216916285418e-03) } },
|
||||
{ { SC_(1.0), SC_(1e+05), SC_(1.846757562882567716362123967114215743694e-03) } },
|
||||
// test zeros:
|
||||
{ { SC_(1.0), T(4017834) / (1024 * 1024), SC_(3.53149033321258645807835062770856949751958513973522222203044e-7) } },
|
||||
{ { SC_(1.0), T(7356375) / (1024 * 1024), SC_(-2.31227973111067286051984021150135526024117175836722748404342e-7) } },
|
||||
{ { SC_(1.0), T(10667654) / (1024 * 1024), SC_(1.24591331097191900488116495350277530373473085499043086981229e-7) } },
|
||||
} };
|
||||
|
||||
static const boost::array<boost::array<typename table_type<T>::type, 3>, 17> jn_data = { {
|
||||
// This first one is a modified test case from https://svn.boost.org/trac/boost/ticket/2733
|
||||
{ { SC_(-1.0), SC_(1.25), SC_(-0.510623260319880467069474837274910375352924050139633057168856) } },
|
||||
{ { SC_(2.0), SC_(0.0), SC_(0.0) } },
|
||||
{ { SC_(-2.0), SC_(0.0), SC_(0.0) } },
|
||||
{ { SC_(2.0), SC_(1e-02), SC_(1.249989583365885362413250958437642113452e-05) } },
|
||||
{ { SC_(5.0), SC_(10.0), SC_(-0.2340615281867936404436949416457777864635) } },
|
||||
{ { SC_(5.0), SC_(-10.0), SC_(0.2340615281867936404436949416457777864635) } },
|
||||
{ { SC_(-5.0), SC_(1e+06), SC_(7.259643842453285052375779970433848914846e-04) } },
|
||||
{ { SC_(5.0), SC_(1e+06), SC_(-0.000725964384245328505237577997043384891484649290328285235308619) } },
|
||||
{ { SC_(-5.0), SC_(-1.0), SC_(2.497577302112344313750655409880451981584e-04) } },
|
||||
{ { SC_(10.0), SC_(10.0), SC_(0.2074861066333588576972787235187534280327) } },
|
||||
{ { SC_(10.0), SC_(-10.0), SC_(0.2074861066333588576972787235187534280327) } },
|
||||
{ { SC_(10.0), SC_(-5.0), SC_(1.467802647310474131107532232606627020895e-03) } },
|
||||
{ { SC_(-10.0), SC_(1e+06), SC_(-3.310793117604488741264958559035744460210e-04) } },
|
||||
{ { SC_(10.0), SC_(1e+06), SC_(-0.000331079311760448874126495855903574446020957243277028930713243) } },
|
||||
{ { SC_(1e+02), SC_(8e+01), SC_(4.606553064823477354141298259169874909670e-06) } },
|
||||
{ { SC_(1e+03), SC_(1e+05), SC_(1.283178112502480365195139312635384057363e-03) } },
|
||||
{ { SC_(10.0), SC_(1e-100), SC_(2.69114445546737213403880070546737213403880070546737213403880e-1010) } },
|
||||
} };
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
#include "bessel_j_int_data.ipp"
|
||||
|
||||
add_data(j0_data);
|
||||
add_data(j0_tricky);
|
||||
add_data(j1_data);
|
||||
add_data(j1_tricky);
|
||||
add_data(jn_data);
|
||||
add_data(bessel_j_int_data);
|
||||
|
||||
unsigned data_total = data.size();
|
||||
|
||||
screen_data([](const std::vector<double>& v){ return boost::math::cyl_bessel_j(static_cast<int>(v[0]), v[1]); }, [](const std::vector<double>& v){ return v[2]; });
|
||||
|
||||
|
||||
#if defined(TEST_C99) && !defined(COMPILER_COMPARISON_TABLES)
|
||||
screen_data([](const std::vector<double>& v){ return ::jn(static_cast<int>(v[0]), v[1]); }, [](const std::vector<double>& v){ return v[2]; });
|
||||
#endif
|
||||
|
||||
unsigned data_used = data.size();
|
||||
std::string function = "cyl_bessel_j (integer order)[br](" + boost::lexical_cast<std::string>(data_used) + "/" + boost::lexical_cast<std::string>(data_total) + " tests selected)";
|
||||
|
||||
double time;
|
||||
|
||||
time = exec_timed_test([](const std::vector<double>& v){ return boost::math::cyl_bessel_j(static_cast<int>(v[0]), v[1]); });
|
||||
std::cout << time << std::endl;
|
||||
report_execution_time(time, std::string("Library Comparison on ") + BOOST_PLATFORM, function, "Boost");
|
||||
//
|
||||
// Boost again, but with promotion to long double turned off:
|
||||
//
|
||||
#if !defined(COMPILER_COMPARISON_TABLES)
|
||||
if(sizeof(long double) != sizeof(double))
|
||||
{
|
||||
time = exec_timed_test([](const std::vector<double>& v){ return boost::math::cyl_bessel_j(static_cast<int>(v[0]), v[1], boost::math::policies::make_policy(boost::math::policies::promote_double<false>())); });
|
||||
std::cout << time << std::endl;
|
||||
report_execution_time(time, std::string("Library Comparison on ") + BOOST_PLATFORM, function, "Boost[br](no internal promotion to long double)");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(TEST_C99) && !defined(COMPILER_COMPARISON_TABLES)
|
||||
time = exec_timed_test([](const std::vector<double>& v){ return ::jn(static_cast<int>(v[0]), v[1]); });
|
||||
std::cout << time << std::endl;
|
||||
report_execution_time(time, std::string("Library Comparison on ") + BOOST_PLATFORM, function, "math.h");
|
||||
#endif
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
68
reporting/performance/test_lgamma.cpp
Normal file
68
reporting/performance/test_lgamma.cpp
Normal file
@@ -0,0 +1,68 @@
|
||||
// Copyright John Maddock 2015.
|
||||
// Use, modification and distribution are subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning (disable : 4224)
|
||||
#endif
|
||||
|
||||
#include <boost/math/special_functions/gamma.hpp>
|
||||
#include <boost/array.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include "../../test/table_type.hpp"
|
||||
#include "table_helper.hpp"
|
||||
#include "performance.hpp"
|
||||
#include <iostream>
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef double T;
|
||||
#define SC_(x) static_cast<double>(x)
|
||||
# include "test_gamma_data.ipp"
|
||||
|
||||
add_data(factorials);
|
||||
add_data(near_0);
|
||||
add_data(near_1);
|
||||
add_data(near_2);
|
||||
add_data(near_m10);
|
||||
add_data(near_m55);
|
||||
|
||||
unsigned data_total = data.size();
|
||||
|
||||
screen_data([](const std::vector<double>& v){ return boost::math::lgamma(v[0]); }, [](const std::vector<double>& v){ return v[2]; });
|
||||
|
||||
|
||||
#if defined(TEST_C99) && !defined(COMPILER_COMPARISON_TABLES)
|
||||
screen_data([](const std::vector<double>& v){ return ::lgamma(v[0]); }, [](const std::vector<double>& v){ return v[2]; });
|
||||
#endif
|
||||
|
||||
unsigned data_used = data.size();
|
||||
std::string function = "lgamma[br](" + boost::lexical_cast<std::string>(data_used) + "/" + boost::lexical_cast<std::string>(data_total) + " tests selected)";
|
||||
|
||||
double time = exec_timed_test([](const std::vector<double>& v){ return boost::math::lgamma(v[0]); });
|
||||
std::cout << time << std::endl;
|
||||
report_execution_time(time, std::string("Library Comparison on ") + BOOST_PLATFORM, function, "Boost");
|
||||
//
|
||||
// Boost again, but with promotion to long double turned off:
|
||||
//
|
||||
#if !defined(COMPILER_COMPARISON_TABLES)
|
||||
if(sizeof(long double) != sizeof(double))
|
||||
{
|
||||
double time = exec_timed_test([](const std::vector<double>& v){ return boost::math::lgamma(v[0], boost::math::policies::make_policy(boost::math::policies::promote_double<false>())); });
|
||||
std::cout << time << std::endl;
|
||||
report_execution_time(time, std::string("Library Comparison on ") + BOOST_PLATFORM, function, "Boost[br](no internal promotion to long double)");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(TEST_C99) && !defined(COMPILER_COMPARISON_TABLES)
|
||||
time = exec_timed_test([](const std::vector<double>& v){ return ::lgamma(v[0]); });
|
||||
std::cout << time << std::endl;
|
||||
report_execution_time(time, std::string("Library Comparison on ") + BOOST_PLATFORM, function, "math.h");
|
||||
#endif
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
62
reporting/performance/test_log1p.cpp
Normal file
62
reporting/performance/test_log1p.cpp
Normal file
@@ -0,0 +1,62 @@
|
||||
// Copyright John Maddock 2015.
|
||||
// Use, modification and distribution are subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning (disable : 4224)
|
||||
#endif
|
||||
|
||||
#include <boost/math/special_functions/log1p.hpp>
|
||||
#include <boost/array.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include "../../test/table_type.hpp"
|
||||
#include "table_helper.hpp"
|
||||
#include "performance.hpp"
|
||||
#include <iostream>
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef double T;
|
||||
#define SC_(x) static_cast<double>(x)
|
||||
# include "../../test/log1p_expm1_data.ipp"
|
||||
|
||||
add_data(log1p_expm1_data);
|
||||
|
||||
unsigned data_total = data.size();
|
||||
|
||||
screen_data([](const std::vector<double>& v){ return boost::math::log1p(v[0]); }, [](const std::vector<double>& v){ return v[1]; });
|
||||
|
||||
#if defined(TEST_C99) && !defined(COMPILER_COMPARISON_TABLES)
|
||||
screen_data([](const std::vector<double>& v){ return ::log1p(v[0]); }, [](const std::vector<double>& v){ return v[1]; });
|
||||
#endif
|
||||
|
||||
unsigned data_used = data.size();
|
||||
std::string function = "log1p[br](" + boost::lexical_cast<std::string>(data_used)+"/" + boost::lexical_cast<std::string>(data_total)+" tests selected)";
|
||||
|
||||
double time = exec_timed_test([](const std::vector<double>& v){ return boost::math::log1p(v[0]); });
|
||||
std::cout << time << std::endl;
|
||||
report_execution_time(time, std::string("Library Comparison on ") + BOOST_PLATFORM, function, "Boost");
|
||||
//
|
||||
// Boost again, but with promotion to long double turned off:
|
||||
//
|
||||
#if !defined(COMPILER_COMPARISON_TABLES)
|
||||
if(sizeof(long double) != sizeof(double))
|
||||
{
|
||||
double time = exec_timed_test([](const std::vector<double>& v){ return boost::math::log1p(v[0], boost::math::policies::make_policy(boost::math::policies::promote_double<false>())); });
|
||||
std::cout << time << std::endl;
|
||||
report_execution_time(time, std::string("Library Comparison on ") + BOOST_PLATFORM, function, "Boost[br](no internal promotion to long double)");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(TEST_C99) && !defined(COMPILER_COMPARISON_TABLES)
|
||||
time = exec_timed_test([](const std::vector<double>& v){ return ::log1p(v[0]); });
|
||||
std::cout << time << std::endl;
|
||||
report_execution_time(time, std::string("Library Comparison on ") + BOOST_PLATFORM, function, "math.h");
|
||||
#endif
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
68
reporting/performance/test_tgamma.cpp
Normal file
68
reporting/performance/test_tgamma.cpp
Normal file
@@ -0,0 +1,68 @@
|
||||
// Copyright John Maddock 2015.
|
||||
// Use, modification and distribution are subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning (disable : 4224)
|
||||
#endif
|
||||
|
||||
#include <boost/math/special_functions/gamma.hpp>
|
||||
#include <boost/array.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include "../../test/table_type.hpp"
|
||||
#include "table_helper.hpp"
|
||||
#include "performance.hpp"
|
||||
#include <iostream>
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef double T;
|
||||
#define SC_(x) static_cast<double>(x)
|
||||
# include "test_gamma_data.ipp"
|
||||
|
||||
add_data(factorials);
|
||||
add_data(near_0);
|
||||
add_data(near_1);
|
||||
add_data(near_2);
|
||||
add_data(near_m10);
|
||||
add_data(near_m55);
|
||||
|
||||
unsigned data_total = data.size();
|
||||
|
||||
screen_data([](const std::vector<double>& v){ return boost::math::tgamma(v[0]); }, [](const std::vector<double>& v){ return v[1]; });
|
||||
|
||||
|
||||
#if defined(TEST_C99) && !defined(COMPILER_COMPARISON_TABLES)
|
||||
screen_data([](const std::vector<double>& v){ return ::tgamma(v[0]); }, [](const std::vector<double>& v){ return v[1]; });
|
||||
#endif
|
||||
|
||||
unsigned data_used = data.size();
|
||||
std::string function = "tgamma[br](" + boost::lexical_cast<std::string>(data_used) + "/" + boost::lexical_cast<std::string>(data_total) + " tests selected)";
|
||||
|
||||
double time = exec_timed_test([](const std::vector<double>& v){ return boost::math::tgamma(v[0]); });
|
||||
std::cout << time << std::endl;
|
||||
report_execution_time(time, std::string("Library Comparison on ") + BOOST_PLATFORM, function, "Boost");
|
||||
//
|
||||
// Boost again, but with promotion to long double turned off:
|
||||
//
|
||||
#if !defined(COMPILER_COMPARISON_TABLES)
|
||||
if(sizeof(long double) != sizeof(double))
|
||||
{
|
||||
double time = exec_timed_test([](const std::vector<double>& v){ return boost::math::tgamma(v[0], boost::math::policies::make_policy(boost::math::policies::promote_double<false>())); });
|
||||
std::cout << time << std::endl;
|
||||
report_execution_time(time, std::string("Library Comparison on ") + BOOST_PLATFORM, function, "Boost[br](no internal promotion to long double)");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(TEST_C99) && !defined(COMPILER_COMPARISON_TABLES)
|
||||
time = exec_timed_test([](const std::vector<double>& v){ return ::tgamma(v[0]); });
|
||||
std::cout << time << std::endl;
|
||||
report_execution_time(time, std::string("Library Comparison on ") + BOOST_PLATFORM, function, "math.h");
|
||||
#endif
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
105
reporting/performance/test_yn.cpp
Normal file
105
reporting/performance/test_yn.cpp
Normal file
@@ -0,0 +1,105 @@
|
||||
// Copyright John Maddock 2015.
|
||||
// Use, modification and distribution are subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning (disable : 4224)
|
||||
#endif
|
||||
|
||||
#include <boost/math/special_functions/bessel.hpp>
|
||||
#include <boost/array.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include "../../test/table_type.hpp"
|
||||
#include "table_helper.hpp"
|
||||
#include "performance.hpp"
|
||||
#include <iostream>
|
||||
|
||||
typedef double T;
|
||||
#define SC_(x) static_cast<double>(x)
|
||||
static const boost::array<boost::array<typename table_type<T>::type, 3>, 9> y0_data = { {
|
||||
{ { SC_(0.0), SC_(1.0), SC_(0.0882569642156769579829267660235151628278175230906755467110438) } },
|
||||
{ { SC_(0.0), SC_(2.0), SC_(0.510375672649745119596606592727157873268139227085846135571839) } },
|
||||
{ { SC_(0.0), SC_(4.0), SC_(-0.0169407393250649919036351344471532182404925898980149027169321) } },
|
||||
{ { SC_(0.0), SC_(8.0), SC_(0.223521489387566220527323400498620359274814930781423577578334) } },
|
||||
{ { SC_(0.0), SC_(1e-05), SC_(-7.40316028370197013259676050746759072070960287586102867247159) } },
|
||||
{ { SC_(0.0), SC_(1e-10), SC_(-14.7325162726972420426916696426209144888762342592762415255386) } },
|
||||
{ { SC_(0.0), SC_(1e-20), SC_(-29.3912282502857968601858410375186700783698345615477536431464) } },
|
||||
{ { SC_(0.0), SC_(1e+03), SC_(0.00471591797762281339977326146566525500985900489680197718528000) } },
|
||||
{ { SC_(0.0), SC_(1e+05), SC_(0.00184676615886506410434074102431546125884886798090392516843524) } }
|
||||
} };
|
||||
static const boost::array<boost::array<typename table_type<T>::type, 3>, 9> y1_data = { {
|
||||
{ { SC_(1.0), SC_(1.0), SC_(-0.781212821300288716547150000047964820549906390716444607843833) } },
|
||||
{ { SC_(1.0), SC_(2.0), SC_(-0.107032431540937546888370772277476636687480898235053860525795) } },
|
||||
{ { SC_(1.0), SC_(4.0), SC_(0.397925710557100005253979972450791852271189181622908340876586) } },
|
||||
{ { SC_(1.0), SC_(8.0), SC_(-0.158060461731247494255555266187483550327344049526705737651263) } },
|
||||
{ { SC_(1.0), SC_(1e-10), SC_(-6.36619772367581343150789184284462611709080831190542841855708e9) } },
|
||||
{ { SC_(1.0), SC_(1e-20), SC_(-6.36619772367581343075535053490057448139324059868649274367256e19) } },
|
||||
{ { SC_(1.0), SC_(1e+01), SC_(0.249015424206953883923283474663222803260416543069658461246944) } },
|
||||
{ { SC_(1.0), SC_(1e+03), SC_(-0.0247843312923517789148623560971412909386318548648705287583490) } },
|
||||
{ { SC_(1.0), SC_(1e+05), SC_(0.00171921035008825630099494523539897102954509504993494957572726) } }
|
||||
} };
|
||||
static const boost::array<boost::array<typename table_type<T>::type, 3>, 10> yn_data = { {
|
||||
{ { SC_(2.0), SC_(1e-20), SC_(-1.27323954473516268615107010698011489627570899691226996904849e40) } },
|
||||
{ { SC_(5.0), SC_(10.0), SC_(0.135403047689362303197029014762241709088405766746419538495983) } },
|
||||
{ { SC_(-5.0), SC_(1e+06), SC_(0.000331052088322609048503535570014688967096938338061796192422114) } },
|
||||
{ { SC_(10.0), SC_(10.0), SC_(-0.359814152183402722051986577343560609358382147846904467526222) } },
|
||||
{ { SC_(10.0), SC_(1e-10), SC_(-1.18280490494334933900960937719565669877576135140014365217993e108) } },
|
||||
{ { SC_(-10.0), SC_(1e+06), SC_(0.000725951969295187086245251366365393653610914686201194434805730) } },
|
||||
{ { SC_(1e+02), SC_(5.0), SC_(-5.08486391602022287993091563093082035595081274976837280338134e115) } },
|
||||
{ { SC_(1e+03), SC_(1e+05), SC_(0.00217254919137684037092834146629212647764581965821326561261181) } },
|
||||
{ { SC_(-1e+03), SC_(7e+02), SC_(-1.88753109980945889960843803284345261796244752396992106755091e77) } },
|
||||
{ { SC_(-25.0), SC_(8.0), SC_(3.45113613777297661997458045843868931827873456761831907587263e8) } }
|
||||
} };
|
||||
|
||||
int main()
|
||||
{
|
||||
#include "bessel_y01_data.ipp"
|
||||
#include "bessel_yn_data.ipp"
|
||||
|
||||
add_data(y0_data);
|
||||
add_data(y1_data);
|
||||
add_data(yn_data);
|
||||
add_data(bessel_y01_data);
|
||||
add_data(bessel_yn_data);
|
||||
|
||||
unsigned data_total = data.size();
|
||||
|
||||
screen_data([](const std::vector<double>& v){ return boost::math::cyl_neumann(static_cast<int>(v[0]), v[1]); }, [](const std::vector<double>& v){ return v[2]; });
|
||||
|
||||
|
||||
#if defined(TEST_C99) && !defined(COMPILER_COMPARISON_TABLES)
|
||||
screen_data([](const std::vector<double>& v){ return ::yn(static_cast<int>(v[0]), v[1]); }, [](const std::vector<double>& v){ return v[2]; });
|
||||
#endif
|
||||
|
||||
unsigned data_used = data.size();
|
||||
std::string function = "cyl_neumann (integer order)[br](" + boost::lexical_cast<std::string>(data_used) + "/" + boost::lexical_cast<std::string>(data_total) + " tests selected)";
|
||||
|
||||
double time;
|
||||
|
||||
time = exec_timed_test([](const std::vector<double>& v){ return boost::math::cyl_neumann(static_cast<int>(v[0]), v[1]); });
|
||||
std::cout << time << std::endl;
|
||||
report_execution_time(time, std::string("Library Comparison on ") + BOOST_PLATFORM, function, "Boost");
|
||||
//
|
||||
// Boost again, but with promotion to long double turned off:
|
||||
//
|
||||
#if !defined(COMPILER_COMPARISON_TABLES)
|
||||
if(sizeof(long double) != sizeof(double))
|
||||
{
|
||||
time = exec_timed_test([](const std::vector<double>& v){ return boost::math::cyl_neumann(static_cast<int>(v[0]), v[1], boost::math::policies::make_policy(boost::math::policies::promote_double<false>())); });
|
||||
std::cout << time << std::endl;
|
||||
report_execution_time(time, std::string("Library Comparison on ") + BOOST_PLATFORM, function, "Boost[br](no internal promotion to long double)");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(TEST_C99) && !defined(COMPILER_COMPARISON_TABLES)
|
||||
time = exec_timed_test([](const std::vector<double>& v){ return ::yn(static_cast<int>(v[0]), v[1]); });
|
||||
std::cout << time << std::endl;
|
||||
report_execution_time(time, std::string("Library Comparison on ") + BOOST_PLATFORM, function, "math.h");
|
||||
#endif
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user