[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master b1eecea 02/14: Stabilize unit-test timing
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master b1eecea 02/14: Stabilize unit-test timing |
Date: |
Mon, 5 Apr 2021 18:26:45 -0400 (EDT) |
branch: master
commit b1eeceab9bfe48847c15982529a9f760711eb582
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
Stabilize unit-test timing
The operations measured in 'mete_*' functions run too quickly for stable
measurements. Inserted a loop into each one, to make it run a hundred
times. Incidentally assigned scalar results to 'volatile' variables, to
prevent the loop from being optimized away.
---
commutation_functions_test.cpp | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/commutation_functions_test.cpp b/commutation_functions_test.cpp
index b56e480..77ebea7 100644
--- a/commutation_functions_test.cpp
+++ b/commutation_functions_test.cpp
@@ -59,7 +59,10 @@ void mete_olcf
,std::vector<double> const& i
)
{
- OLCommFns(q, i);
+ for(int j = 0; j < 100; ++j)
+ {
+ volatile auto z = OLCommFns(q, i);
+ }
}
void mete_ulcf
@@ -68,7 +71,10 @@ void mete_ulcf
,std::vector<double> const& ig
)
{
- ULCommFns(q, ic, ig, mce_option1_for_7702, mce_monthly);
+ for(int j = 0; j < 100; ++j)
+ {
+ volatile auto z = ULCommFns(q, ic, ig, mce_option1_for_7702,
mce_monthly);
+ }
}
void mete_reserve
@@ -76,9 +82,12 @@ void mete_reserve
,std::vector<double>& reserve
)
{
- double premium = (10.0 * ulcf.aDomega() + ulcf.kM()[0]) / ulcf.aN()[0];
- assign(reserve, premium * ulcf.aD() - ulcf.kC());
- assign(reserve, fwd_sum(reserve) / ulcf.EaD());
+ for(int j = 0; j < 100; ++j)
+ {
+ volatile double premium = (10.0 * ulcf.aDomega() + ulcf.kM()[0]) /
ulcf.aN()[0];
+ assign(reserve, premium * ulcf.aD() - ulcf.kC());
+ assign(reserve, fwd_sum(reserve) / ulcf.EaD());
+ }
}
/// Exactly reproduce Table 2 from Eckley's paper.
- [lmi-commits] [lmi] master updated (dd6ee0a -> 8aa09b9), Greg Chicares, 2021/04/05
- [lmi-commits] [lmi] master 40218dc 03/14: Factor out commutation-function speed tests, Greg Chicares, 2021/04/05
- [lmi-commits] [lmi] master b8f43e0 06/14: Transpose several unit-test functions, Greg Chicares, 2021/04/05
- [lmi-commits] [lmi] master e6ed669 01/14: Test guideline premium calculations with more complications, Greg Chicares, 2021/04/05
- [lmi-commits] [lmi] master b1eecea 02/14: Stabilize unit-test timing,
Greg Chicares <=
- [lmi-commits] [lmi] master 28cabc2 04/14: Prefer lambdas to std::bind(), Greg Chicares, 2021/04/05
- [lmi-commits] [lmi] master 61a04eb 08/14: Make commutation functions default constructible, Greg Chicares, 2021/04/05
- [lmi-commits] [lmi] master df25463 12/14: Avoid operator new, Greg Chicares, 2021/04/05
- [lmi-commits] [lmi] master b657767 13/14: Remove conditionals that serve no further purpose, Greg Chicares, 2021/04/05
- [lmi-commits] [lmi] master 23fe71f 11/14: Do away with an undesirable smart pointer [290], Greg Chicares, 2021/04/05
- [lmi-commits] [lmi] master 485e19b 07/14: Favor the rule of zero, Greg Chicares, 2021/04/05
- [lmi-commits] [lmi] master 762056e 05/14: Prefer PETE's operator<<=() to assign(), Greg Chicares, 2021/04/05
- [lmi-commits] [lmi] master ed251fc 09/14: Test implicit special member functions, Greg Chicares, 2021/04/05
- [lmi-commits] [lmi] master c2087ae 10/14: Update a comment, Greg Chicares, 2021/04/05
- [lmi-commits] [lmi] master 8aa09b9 14/14: Expunge some pointless defect markers [287], Greg Chicares, 2021/04/05