[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] valyuta/005 86cba7f 09/10: Temporarily don't use cur
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] valyuta/005 86cba7f 09/10: Temporarily don't use currency class |
Date: |
Thu, 21 Jan 2021 17:48:16 -0500 (EST) |
branch: valyuta/005
commit 86cba7f81d21a17b6f16a23c9fa2a05862aa1a23
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
Temporarily don't use currency class
One might hope that the speed would be similar to production, but such
is not the case. Compared to the latest master commit dfdbf3c5a73
(20210116T1657Z), this branch has a penalty of roughly
- forty percent for the no-solve scenario; and
- ten percent for scenarios with a solve or two; yet
- for scenarios with the most solves: about seven percent for
pc-linux-gnu, but nearly zero for 32- or 64-bit msw.
It is more useful to compare the absolute rather than relative
differences: for pc-linux-gnu, the absolute difference is almost
the same across all scenarios, suggesting that there's an initial
setup cost that has increased, but once that's paid there's not
much difference in the cost of each solve, i.e., each complete run
through the monthiversary loop. The absolute differences for msw are
less uniform, but then again the code is quite different (notably,
product-file reads are cached on this branch), so perhaps what's
actually curious is the uniformity observed with pc-linux-gnu.
---
Speed_gcc_i686-w64-mingw32 | 12 ++++++------
Speed_gcc_x86_64-pc-linux-gnu | 12 ++++++------
Speed_gcc_x86_64-w64-mingw32 | 12 ++++++------
currency.hpp | 4 ++--
currency_test.cpp | 9 +++++++--
round_to_test.cpp | 4 ++++
6 files changed, 31 insertions(+), 22 deletions(-)
diff --git a/Speed_gcc_i686-w64-mingw32 b/Speed_gcc_i686-w64-mingw32
index a5fe19f..a5d4251 100644
--- a/Speed_gcc_i686-w64-mingw32
+++ b/Speed_gcc_i686-w64-mingw32
@@ -1,7 +1,7 @@
Test speed:
- naic, no solve : 4.831e-02 s mean; 48156 us least of 21 runs
- naic, specamt solve : 9.056e-02 s mean; 90364 us least of 12 runs
- naic, ee prem solve : 8.270e-02 s mean; 82552 us least of 13 runs
- finra, no solve : 1.618e-02 s mean; 15743 us least of 62 runs
- finra, specamt solve: 5.652e-02 s mean; 54358 us least of 18 runs
- finra, ee prem solve: 5.036e-02 s mean; 50200 us least of 20 runs
+ naic, no solve : 4.877e-02 s mean; 48452 us least of 21 runs
+ naic, specamt solve : 9.172e-02 s mean; 91198 us least of 11 runs
+ naic, ee prem solve : 8.385e-02 s mean; 83264 us least of 12 runs
+ finra, no solve : 1.603e-02 s mean; 15850 us least of 63 runs
+ finra, specamt solve: 5.544e-02 s mean; 55009 us least of 19 runs
+ finra, ee prem solve: 5.117e-02 s mean; 50668 us least of 20 runs
diff --git a/Speed_gcc_x86_64-pc-linux-gnu b/Speed_gcc_x86_64-pc-linux-gnu
index 0493db3..1dbc9d0 100644
--- a/Speed_gcc_x86_64-pc-linux-gnu
+++ b/Speed_gcc_x86_64-pc-linux-gnu
@@ -1,7 +1,7 @@
Test speed:
- naic, no solve : 1.734e-02 s mean; 16554 us least of 58 runs
- naic, specamt solve : 3.106e-02 s mean; 30265 us least of 33 runs
- naic, ee prem solve : 2.827e-02 s mean; 27783 us least of 36 runs
- finra, no solve : 5.503e-03 s mean; 5201 us least of 100 runs
- finra, specamt solve: 1.845e-02 s mean; 18055 us least of 55 runs
- finra, ee prem solve: 1.700e-02 s mean; 16579 us least of 59 runs
+ naic, no solve : 1.688e-02 s mean; 16604 us least of 60 runs
+ naic, specamt solve : 3.098e-02 s mean; 30560 us least of 33 runs
+ naic, ee prem solve : 2.835e-02 s mean; 27963 us least of 36 runs
+ finra, no solve : 5.505e-03 s mean; 5368 us least of 100 runs
+ finra, specamt solve: 1.850e-02 s mean; 17950 us least of 55 runs
+ finra, ee prem solve: 1.715e-02 s mean; 16793 us least of 59 runs
diff --git a/Speed_gcc_x86_64-w64-mingw32 b/Speed_gcc_x86_64-w64-mingw32
index f970c0a..4b4c540 100644
--- a/Speed_gcc_x86_64-w64-mingw32
+++ b/Speed_gcc_x86_64-w64-mingw32
@@ -1,7 +1,7 @@
Test speed:
- naic, no solve : 2.483e-02 s mean; 24523 us least of 41 runs
- naic, specamt solve : 4.254e-02 s mean; 42068 us least of 24 runs
- naic, ee prem solve : 3.906e-02 s mean; 38668 us least of 26 runs
- finra, no solve : 1.013e-02 s mean; 9900 us least of 99 runs
- finra, specamt solve: 2.728e-02 s mean; 26028 us least of 37 runs
- finra, ee prem solve: 2.456e-02 s mean; 24206 us least of 41 runs
+ naic, no solve : 2.581e-02 s mean; 24554 us least of 39 runs
+ naic, specamt solve : 4.269e-02 s mean; 42124 us least of 24 runs
+ naic, ee prem solve : 3.927e-02 s mean; 38772 us least of 26 runs
+ finra, no solve : 1.022e-02 s mean; 9941 us least of 98 runs
+ finra, specamt solve: 2.638e-02 s mean; 25978 us least of 38 runs
+ finra, ee prem solve: 2.462e-02 s mean; 24272 us least of 41 runs
diff --git a/currency.hpp b/currency.hpp
index 2784c81..d9aa655 100644
--- a/currency.hpp
+++ b/currency.hpp
@@ -33,7 +33,7 @@
// elsewhere. Eventually they'll both be eliminated, along with
// all code along paths where they aren't both defined.
-#define USE_CURRENCY_CLASS
+//#define USE_CURRENCY_CLASS
#if !defined USE_CURRENCY_CLASS
# undef CURRENCY_UNIT_IS_CENTS // Requires currency class.
@@ -51,7 +51,7 @@ inline std::vector<double> dblize(std::vector<currency>
const& z)
#else // defined USE_CURRENCY_CLASS
-//# define CURRENCY_UNIT_IS_CENTS
+# define CURRENCY_UNIT_IS_CENTS
class raw_cents {}; // Tag class.
diff --git a/currency_test.cpp b/currency_test.cpp
index c715500..ecd1872 100644
--- a/currency_test.cpp
+++ b/currency_test.cpp
@@ -59,6 +59,7 @@ class currency_test
void currency_test::test()
{
+#if defined USE_CURRENCY_CLASS
test_default_ctor();
test_copy_ctor();
test_explicit_ctor();
@@ -66,7 +67,7 @@ void currency_test::test()
// CURRENCY !! Most of these tests assume that the currency unit is
// cents. It's not worth adapting them to any other case because
// soon this macro will, in effect, always be defined.
-#if defined CURRENCY_UNIT_IS_CENTS
+# if defined CURRENCY_UNIT_IS_CENTS
test_plus_or_minus_eq();
test_plus_or_minus();
test_times_int();
@@ -78,9 +79,11 @@ void currency_test::test()
test_round_double();
test_round_currency();
test_quodlibet();
-#endif // defined CURRENCY_UNIT_IS_CENTS
+# endif // defined CURRENCY_UNIT_IS_CENTS
+#endif // defined USE_CURRENCY_CLASS
}
+#if defined USE_CURRENCY_CLASS
void currency_test::test_default_ctor()
{
// default ctor
@@ -279,6 +282,8 @@ std::cout << big_int3 << '\n' << 1.0e102 << '\n' <<
big_int3 - 1.0e102 << std::e
);
#endif // 0
+#endif // defined USE_CURRENCY_CLASS
+
int test_main(int, char*[])
{
currency_test::test();
diff --git a/round_to_test.cpp b/round_to_test.cpp
index e438d37..bf7fdaf 100644
--- a/round_to_test.cpp
+++ b/round_to_test.cpp
@@ -580,12 +580,14 @@ void round_to_test::test_fundamentals()
// Test rounding double to currency.
currency c = round0.c(1.61803398875);
BOOST_TEST((1.62 - dblize(c)) < 1e-14);
+#if defined USE_CURRENCY_CLASS
# if defined CURRENCY_UNIT_IS_CENTS
BOOST_TEST_EQUAL(162, c.cents());
# else // !defined CURRENCY_UNIT_IS_CENTS
// Arguably this isn't quite meaningful:
BOOST_TEST_EQUAL(1.62, c.cents());
# endif // !defined CURRENCY_UNIT_IS_CENTS
+#endif // defined USE_CURRENCY_CLASS
// c *= 0.61803398875;
// BOOST_TEST_EQUAL(1, c);
@@ -596,6 +598,7 @@ void round_to_test::test_fundamentals()
BOOST_TEST((3.14 - v1[0]) < 1e-14);
BOOST_TEST((2.72 - v1[1]) < 1e-14);
+#if defined USE_CURRENCY_CLASS
// Try to provoke division by zero in ctor-initializer.
//
// nonstd::power() negates a negative exponent, but negating
@@ -606,6 +609,7 @@ void round_to_test::test_fundamentals()
,std::domain_error
,"Invalid number of decimals."
);
+#endif // defined USE_CURRENCY_CLASS
}
void round_to_test::test()
- [lmi-commits] [lmi] valyuta/005 updated (133d646 -> 9e42155), Greg Chicares, 2021/01/21
- [lmi-commits] [lmi] valyuta/005 d763c34 04/10: Clean up, Greg Chicares, 2021/01/21
- [lmi-commits] [lmi] valyuta/005 2712277 02/10: Default class currency's special member functions, Greg Chicares, 2021/01/21
- [lmi-commits] [lmi] valyuta/005 86cba7f 09/10: Temporarily don't use currency class,
Greg Chicares <=
- [lmi-commits] [lmi] valyuta/005 7f6a453 01/10: Revert "Partially revert the last commit", Greg Chicares, 2021/01/21
- [lmi-commits] [lmi] valyuta/005 c0a93cf 03/10: Reorder currency unit tests, Greg Chicares, 2021/01/21
- [lmi-commits] [lmi] valyuta/005 e40980b 05/10: Optionally detect nonintegral cents at run time, Greg Chicares, 2021/01/21
- [lmi-commits] [lmi] valyuta/005 61396fd 06/10: Expunge the unclean macro just added, Greg Chicares, 2021/01/21
- [lmi-commits] [lmi] valyuta/005 4b0bf87 07/10: Detect nonintegral cents along every path, Greg Chicares, 2021/01/21
- [lmi-commits] [lmi] valyuta/005 6767160 08/10: Temporarily don't use cents, Greg Chicares, 2021/01/21
- [lmi-commits] [lmi] valyuta/005 9e42155 10/10: Undo temporary changes: use currency class with cents, Greg Chicares, 2021/01/21