[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master b1d57e5 5/6: Establish another soon-to-become
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master b1d57e5 5/6: Establish another soon-to-become-useful invariant |
Date: |
Fri, 22 Jan 2021 21:55:54 -0500 (EST) |
branch: master
commit b1d57e539fa220e74e49365291592c93721bb41c
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
Establish another soon-to-become-useful invariant
Invariant: product files of all types can be read from cache.
That doesn't mean they are all read from cache all the time--not yet;
it just means that they can be; and indeed, speed changed immaterially.
This unit test output:
Read all, cached' : 4.624e-05 s mean; 46 us least of 217 runs
initially seemed surprising: why isn't it a thousand times faster, say?
A casual experiment suggests that half of that time is spent checking
timestamps; there would seem to be little to gain by delving further
into it.
---
Speed_gcc_i686-w64-mingw32 | 12 +++++------
Speed_gcc_x86_64-pc-linux-gnu | 12 +++++------
Speed_gcc_x86_64-w64-mingw32 | 12 +++++------
fund_data.hpp | 2 ++
product_data.hpp | 2 ++
product_file_test.cpp | 47 ++++++++++++++++++++++++++-----------------
rounding_rules.hpp | 2 ++
stratified_charges.hpp | 6 ++++--
8 files changed, 56 insertions(+), 39 deletions(-)
diff --git a/Speed_gcc_i686-w64-mingw32 b/Speed_gcc_i686-w64-mingw32
index 0ef4f39..d454565 100644
--- a/Speed_gcc_i686-w64-mingw32
+++ b/Speed_gcc_i686-w64-mingw32
@@ -1,7 +1,7 @@
Test speed:
- naic, no solve : 5.230e-02 s mean; 52049 us least of 20 runs
- naic, specamt solve : 9.288e-02 s mean; 92504 us least of 11 runs
- naic, ee prem solve : 8.521e-02 s mean; 84843 us least of 12 runs
- finra, no solve : 2.267e-02 s mean; 21715 us least of 45 runs
- finra, specamt solve: 5.912e-02 s mean; 58920 us least of 17 runs
- finra, ee prem solve: 5.499e-02 s mean; 54843 us least of 19 runs
+ naic, no solve : 5.266e-02 s mean; 52033 us least of 19 runs
+ naic, specamt solve : 9.338e-02 s mean; 92473 us least of 11 runs
+ naic, ee prem solve : 8.551e-02 s mean; 84842 us least of 12 runs
+ finra, no solve : 2.208e-02 s mean; 21730 us least of 46 runs
+ finra, specamt solve: 5.952e-02 s mean; 58993 us least of 17 runs
+ finra, ee prem solve: 5.544e-02 s mean; 54749 us least of 19 runs
diff --git a/Speed_gcc_x86_64-pc-linux-gnu b/Speed_gcc_x86_64-pc-linux-gnu
index e24d505..82b22a1 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.931e-02 s mean; 18603 us least of 52 runs
- naic, specamt solve : 3.349e-02 s mean; 32661 us least of 30 runs
- naic, ee prem solve : 3.070e-02 s mean; 29998 us least of 33 runs
- finra, no solve : 7.805e-03 s mean; 7343 us least of 100 runs
- finra, specamt solve: 2.070e-02 s mean; 19991 us least of 49 runs
- finra, ee prem solve: 1.939e-02 s mean; 18827 us least of 52 runs
+ naic, no solve : 1.919e-02 s mean; 18722 us least of 53 runs
+ naic, specamt solve : 3.322e-02 s mean; 32686 us least of 31 runs
+ naic, ee prem solve : 3.058e-02 s mean; 29995 us least of 33 runs
+ finra, no solve : 7.656e-03 s mean; 7307 us least of 100 runs
+ finra, specamt solve: 2.072e-02 s mean; 20184 us least of 49 runs
+ finra, ee prem solve: 1.929e-02 s mean; 18870 us least of 52 runs
diff --git a/Speed_gcc_x86_64-w64-mingw32 b/Speed_gcc_x86_64-w64-mingw32
index c71751c..b884f04 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.675e-02 s mean; 26450 us least of 38 runs
- naic, specamt solve : 4.205e-02 s mean; 41529 us least of 24 runs
- naic, ee prem solve : 3.904e-02 s mean; 38621 us least of 26 runs
- finra, no solve : 1.460e-02 s mean; 14275 us least of 69 runs
- finra, specamt solve: 2.875e-02 s mean; 28409 us least of 35 runs
- finra, ee prem solve: 2.731e-02 s mean; 27011 us least of 37 runs
+ naic, no solve : 2.679e-02 s mean; 26405 us least of 38 runs
+ naic, specamt solve : 4.213e-02 s mean; 41608 us least of 24 runs
+ naic, ee prem solve : 3.933e-02 s mean; 38708 us least of 26 runs
+ finra, no solve : 1.489e-02 s mean; 14508 us least of 68 runs
+ finra, specamt solve: 2.912e-02 s mean; 28617 us least of 35 runs
+ finra, ee prem solve: 2.753e-02 s mean; 27051 us least of 37 runs
diff --git a/fund_data.hpp b/fund_data.hpp
index a54ab21..08ad26b 100644
--- a/fund_data.hpp
+++ b/fund_data.hpp
@@ -24,6 +24,7 @@
#include "config.hpp"
+#include "cache_file_reads.hpp"
#include "so_attributes.hpp"
#include <boost/filesystem/path.hpp>
@@ -62,6 +63,7 @@ class LMI_SO FundInfo final
};
class LMI_SO FundData final
+ :public cache_file_reads<FundData>
{
public:
explicit FundData(fs::path const& a_Filename);
diff --git a/product_data.hpp b/product_data.hpp
index fc8cb6e..c7bd1c4 100644
--- a/product_data.hpp
+++ b/product_data.hpp
@@ -25,6 +25,7 @@
#include "config.hpp"
#include "any_member.hpp"
+#include "cache_file_reads.hpp"
#include "so_attributes.hpp"
#include "xml_serializable.hpp"
@@ -81,6 +82,7 @@ template<> struct deserialized<product_data>
class LMI_SO product_data
:public xml_serializable <product_data>
,public MemberSymbolTable <product_data>
+ ,public cache_file_reads <product_data>
{
friend class BasicValues; // For antediluvian fork only.
friend class PolicyDocument;
diff --git a/product_file_test.cpp b/product_file_test.cpp
index a0fd21f..5c90d27 100644
--- a/product_file_test.cpp
+++ b/product_file_test.cpp
@@ -37,6 +37,8 @@
#include "test_tools.hpp"
#include "timer.hpp" // TimeAnAliquot()
+#include <boost/filesystem/path.hpp>
+
#include <string>
#include <utility> // move()
@@ -62,25 +64,26 @@ class product_file_test
static void read_policy_file() ;
static void read_rounding_file() ;
static void read_stratified_file() ;
-
- static std::string database_filename_ ;
- static std::string fund_filename_ ;
- static std::string lingo_filename_ ;
- static std::string policy_filename_ ;
- static std::string rounding_filename_ ;
- static std::string stratified_filename_ ;
+ static void read_cached_files() ;
+
+ static fs::path database_filename_ ;
+ static fs::path fund_filename_ ;
+ static fs::path lingo_filename_ ;
+ static fs::path policy_filename_ ;
+ static fs::path rounding_filename_ ;
+ static fs::path stratified_filename_ ;
};
-std::string product_file_test::database_filename_ ;
-std::string product_file_test::fund_filename_ ;
-std::string product_file_test::lingo_filename_ ;
-std::string product_file_test::policy_filename_ ;
-std::string product_file_test::rounding_filename_ ;
-std::string product_file_test::stratified_filename_ ;
+fs::path product_file_test::database_filename_ ;
+fs::path product_file_test::fund_filename_ ;
+fs::path product_file_test::lingo_filename_ ;
+fs::path product_file_test::policy_filename_ ;
+fs::path product_file_test::rounding_filename_ ;
+fs::path product_file_test::stratified_filename_ ;
void product_file_test::get_filenames()
{
- policy_filename_ = "sample";
+ policy_filename_ = filename_from_product_name("sample");
product_data p(policy_filename_);
database_filename_ = AddDataDir(p.datum("DatabaseFilename"));
fund_filename_ = AddDataDir(p.datum("FundFilename" ));
@@ -138,11 +141,6 @@ void product_file_test::test_copying()
BOOST_TEST( 99 == g.query<int>(DB_MaxIncrAge));
}
-// This implementation:
-// auto z = DBDictionary::read_via_cache(database_filename_);
-// would cause assay_speed() to report a much faster run time,
-// yet such a timing would have little significance.
-
void product_file_test::read_database_file()
{
DBDictionary z(database_filename_);
@@ -173,6 +171,16 @@ void product_file_test::read_stratified_file()
stratified_charges z(stratified_filename_);
}
+void product_file_test::read_cached_files()
+{
+ DBDictionary ::read_via_cache(database_filename_);
+ FundData ::read_via_cache(fund_filename_);
+ lingo ::read_via_cache(lingo_filename_);
+ product_data ::read_via_cache(policy_filename_);
+ rounding_rules ::read_via_cache(rounding_filename_);
+ stratified_charges ::read_via_cache(stratified_filename_);
+}
+
void product_file_test::assay_speed()
{
std::cout
@@ -183,6 +191,7 @@ void product_file_test::assay_speed()
<< "\n Read 'policy' : " << TimeAnAliquot(read_policy_file )
<< "\n Read 'rounding' : " << TimeAnAliquot(read_rounding_file )
<< "\n Read 'stratified' : " << TimeAnAliquot(read_stratified_file)
+ << "\n Read all, cached' : " << TimeAnAliquot(read_cached_files )
<< '\n'
;
}
diff --git a/rounding_rules.hpp b/rounding_rules.hpp
index 37872d5..3f2070c 100644
--- a/rounding_rules.hpp
+++ b/rounding_rules.hpp
@@ -25,6 +25,7 @@
#include "config.hpp"
#include "any_member.hpp"
+#include "cache_file_reads.hpp"
#include "mc_enum.hpp"
#include "mc_enum_types.hpp"
#include "so_attributes.hpp"
@@ -93,6 +94,7 @@ class LMI_SO rounding_parameters final
class LMI_SO rounding_rules final
:public xml_serializable <rounding_rules>
,public MemberSymbolTable <rounding_rules>
+ ,public cache_file_reads <rounding_rules>
{
friend class RoundingDocument;
diff --git a/stratified_charges.hpp b/stratified_charges.hpp
index f703c49..3cfc85d 100644
--- a/stratified_charges.hpp
+++ b/stratified_charges.hpp
@@ -25,6 +25,7 @@
#include "config.hpp"
#include "any_member.hpp"
+#include "cache_file_reads.hpp"
#include "mc_enum_type_enums.hpp"
#include "so_attributes.hpp"
#include "xml_serializable.hpp"
@@ -99,8 +100,9 @@ class LMI_SO stratified_entity final
/// Rates that depend upon the amount they're multiplied by.
class LMI_SO stratified_charges final
- :public xml_serializable <stratified_charges>
- ,public MemberSymbolTable <stratified_charges>
+ :public xml_serializable <stratified_charges>
+ ,public MemberSymbolTable <stratified_charges>
+ ,public cache_file_reads <stratified_charges>
{
friend class TierDocument;
- [lmi-commits] [lmi] master updated (19222f8 -> a111350), Greg Chicares, 2021/01/22
- [lmi-commits] [lmi] master bd30a5c 4/6: Change class cache_file_reads<>'s key type, Greg Chicares, 2021/01/22
- [lmi-commits] [lmi] master a111350 6/6: C++17ize, Greg Chicares, 2021/01/22
- [lmi-commits] [lmi] master b1d57e5 5/6: Establish another soon-to-become-useful invariant,
Greg Chicares <=
- [lmi-commits] [lmi] master 84086c5 1/6: Note a spelling error in a literal quote, Greg Chicares, 2021/01/22
- [lmi-commits] [lmi] master 0fc4f3f 3/6: Correct a misapprehension, Greg Chicares, 2021/01/22
- [lmi-commits] [lmi] master 8252fb3 2/6: Establish an invariant that will become useful ere long, Greg Chicares, 2021/01/22