lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [lmi] master eb70cdc 7/7: Prefer not to pass std::vector b


From: Greg Chicares
Subject: [lmi-commits] [lmi] master eb70cdc 7/7: Prefer not to pass std::vector by value
Date: Sat, 16 Jan 2021 04:07:20 -0500 (EST)

branch: master
commit eb70cdc84c20ee2f48a151d5f37913198cf7dbaf
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>

    Prefer not to pass std::vector by value
    
    These changes might improve speed by one percent or so, but an effect
    that small cannot be measured reliably.
---
 Speed_gcc_i686-w64-mingw32    | 12 ++++++------
 Speed_gcc_x86_64-pc-linux-gnu | 12 ++++++------
 Speed_gcc_x86_64-w64-mingw32  | 12 ++++++------
 dbo_rules.cpp                 |  2 +-
 dbo_rules.hpp                 |  2 +-
 report_table_test.cpp         |  2 +-
 round_to.hpp                  |  5 +++--
 7 files changed, 24 insertions(+), 23 deletions(-)

diff --git a/Speed_gcc_i686-w64-mingw32 b/Speed_gcc_i686-w64-mingw32
index 6fc22f6..6b0f9cb 100644
--- a/Speed_gcc_i686-w64-mingw32
+++ b/Speed_gcc_i686-w64-mingw32
@@ -1,7 +1,7 @@
 Test speed:
-  naic, no solve      : 5.307e-02 s mean;      52248 us least of  19 runs
-  naic, specamt solve : 9.451e-02 s mean;      92868 us least of  11 runs
-  naic, ee prem solve : 8.641e-02 s mean;      85247 us least of  12 runs
-  finra, no solve     : 2.213e-02 s mean;      21762 us least of  46 runs
-  finra, specamt solve: 5.981e-02 s mean;      59198 us least of  17 runs
-  finra, ee prem solve: 5.614e-02 s mean;      55063 us least of  18 runs
+  naic, no solve      : 5.456e-02 s mean;      51931 us least of  19 runs
+  naic, specamt solve : 9.267e-02 s mean;      92286 us least of  11 runs
+  naic, ee prem solve : 8.516e-02 s mean;      84830 us least of  12 runs
+  finra, no solve     : 2.183e-02 s mean;      21703 us least of  46 runs
+  finra, specamt solve: 5.913e-02 s mean;      58925 us least of  17 runs
+  finra, ee prem solve: 5.501e-02 s mean;      54808 us least of  19 runs
diff --git a/Speed_gcc_x86_64-pc-linux-gnu b/Speed_gcc_x86_64-pc-linux-gnu
index c345d58..dad77b7 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.965e-02 s mean;      18957 us least of  51 runs
-  naic, specamt solve : 3.346e-02 s mean;      32667 us least of  30 runs
-  naic, ee prem solve : 3.081e-02 s mean;      30138 us least of  33 runs
-  finra, no solve     : 7.876e-03 s mean;       7616 us least of 100 runs
-  finra, specamt solve: 2.083e-02 s mean;      20463 us least of  48 runs
-  finra, ee prem solve: 1.949e-02 s mean;      18879 us least of  52 runs
+  naic, no solve      : 1.918e-02 s mean;      18753 us least of  53 runs
+  naic, specamt solve : 3.312e-02 s mean;      32434 us least of  31 runs
+  naic, ee prem solve : 3.046e-02 s mean;      30031 us least of  33 runs
+  finra, no solve     : 7.629e-03 s mean;       7377 us least of 100 runs
+  finra, specamt solve: 2.056e-02 s mean;      20093 us least of  49 runs
+  finra, ee prem solve: 1.913e-02 s mean;      18751 us least of  53 runs
diff --git a/Speed_gcc_x86_64-w64-mingw32 b/Speed_gcc_x86_64-w64-mingw32
index 00ccc0f..139c622 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.779e-02 s mean;      26362 us least of  36 runs
-  naic, specamt solve : 4.214e-02 s mean;      41570 us least of  24 runs
-  naic, ee prem solve : 3.924e-02 s mean;      38670 us least of  26 runs
-  finra, no solve     : 1.489e-02 s mean;      14589 us least of  68 runs
-  finra, specamt solve: 2.901e-02 s mean;      28609 us least of  35 runs
-  finra, ee prem solve: 2.750e-02 s mean;      27122 us least of  37 runs
+  naic, no solve      : 2.674e-02 s mean;      26388 us least of  38 runs
+  naic, specamt solve : 4.206e-02 s mean;      41541 us least of  24 runs
+  naic, ee prem solve : 3.916e-02 s mean;      38679 us least of  26 runs
+  finra, no solve     : 1.476e-02 s mean;      14484 us least of  68 runs
+  finra, specamt solve: 2.882e-02 s mean;      28440 us least of  35 runs
+  finra, ee prem solve: 2.728e-02 s mean;      26912 us least of  37 runs
diff --git a/dbo_rules.cpp b/dbo_rules.cpp
index 84be0b2..0fa52f0 100644
--- a/dbo_rules.cpp
+++ b/dbo_rules.cpp
@@ -96,7 +96,7 @@ bool dbo_transition_is_allowed(mce_dbopt from, mce_dbopt to)
 
 // The return value is fairly useless, and may later be removed.
 
-bool dbo_sequence_is_allowed(std::vector<mce_dbopt> v)
+bool dbo_sequence_is_allowed(std::vector<mce_dbopt> const& v)
 {
     if(0 == lmi::ssize(v))
         {
diff --git a/dbo_rules.hpp b/dbo_rules.hpp
index 205767d..4206326 100644
--- a/dbo_rules.hpp
+++ b/dbo_rules.hpp
@@ -32,6 +32,6 @@
 
 bool dbo_at_issue_is_allowed(mce_dbopt);
 bool dbo_transition_is_allowed(mce_dbopt from, mce_dbopt to);
-bool dbo_sequence_is_allowed(std::vector<mce_dbopt>);
+bool dbo_sequence_is_allowed(std::vector<mce_dbopt> const&);
 
 #endif // dbo_rules_hpp
diff --git a/report_table_test.cpp b/report_table_test.cpp
index b10b3c8..3beadbb 100644
--- a/report_table_test.cpp
+++ b/report_table_test.cpp
@@ -69,7 +69,7 @@ std::vector<table_column_info> bloat
     return v;
 }
 
-int sum(std::vector<int> z)
+int sum(std::vector<int> const& z)
 {
     return std::accumulate(z.begin(), z.end(), 0);
 }
diff --git a/round_to.hpp b/round_to.hpp
index 2338e24..4d551a7 100644
--- a/round_to.hpp
+++ b/round_to.hpp
@@ -264,7 +264,7 @@ class round_to
 
     bool operator==(round_to const&) const;
     RealType operator()(RealType r) const;
-    std::vector<RealType> operator()(std::vector<RealType> r) const;
+    std::vector<RealType> operator()(std::vector<RealType> const& r) const;
 
     int decimals() const;
     rounding_style style() const;
@@ -361,7 +361,8 @@ inline RealType round_to<RealType>::operator()(RealType r) 
const
 }
 
 template<typename RealType>
-inline std::vector<RealType> 
round_to<RealType>::operator()(std::vector<RealType> r) const
+inline std::vector<RealType> round_to<RealType>::operator()
+    (std::vector<RealType> const& r) const
 {
     std::vector<RealType> z;
     z.reserve(r.size());



reply via email to

[Prev in Thread] Current Thread [Next in Thread]