You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datasketches.apache.org by al...@apache.org on 2019/12/03 18:25:16 UTC

[incubator-datasketches-characterization] 02/02: removed unnecessarily limiting const from run() and other cleanup

This is an automated email from the ASF dual-hosted git repository.

alsay pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-datasketches-characterization.git

commit d90968721f5fdf205cd2ee2cd510a9f2f399be74
Author: AlexanderSaydakov <Al...@users.noreply.github.com>
AuthorDate: Mon Dec 2 16:33:56 2019 -0800

    removed unnecessarily limiting const from run() and other cleanup
---
 cpp/src/cpc_sketch_timing_profile.cpp              |  2 +-
 cpp/src/cpc_sketch_timing_profile.hpp              |  2 +-
 cpp/src/cpc_union_timing_profile.cpp               |  2 +-
 cpp/src/cpc_union_timing_profile.hpp               |  2 +-
 cpp/src/frequent_items_sketch_accuracy_profile.cpp |  2 +-
 cpp/src/frequent_items_sketch_accuracy_profile.hpp |  2 +-
 cpp/src/frequent_items_sketch_timing_profile.cpp   |  2 +-
 cpp/src/frequent_items_sketch_timing_profile.hpp   |  2 +-
 cpp/src/hll_union_timing_profile.cpp               |  2 +-
 cpp/src/hll_union_timing_profile.hpp               |  2 +-
 cpp/src/job_profile.cpp                            | 14 +++++++-------
 cpp/src/job_profile.hpp                            |  4 ++--
 cpp/src/kll_accuracy_profile.cpp                   | 16 ++++++++--------
 cpp/src/kll_accuracy_profile.hpp                   |  4 ++--
 cpp/src/kll_merge_accuracy_profile.cpp             |  8 ++++----
 cpp/src/kll_merge_accuracy_profile.hpp             |  2 +-
 cpp/src/kll_sketch_accuracy_profile.cpp            |  2 +-
 cpp/src/kll_sketch_accuracy_profile.hpp            |  2 +-
 cpp/src/kll_sketch_timing_profile.cpp              |  2 +-
 cpp/src/kll_sketch_timing_profile.hpp              |  2 +-
 cpp/src/main.cpp                                   |  2 +-
 cpp/src/theta_sketch_timing_profile.cpp            |  2 +-
 cpp/src/theta_sketch_timing_profile.hpp            |  2 +-
 cpp/src/theta_union_timing_profile.cpp             |  2 +-
 cpp/src/theta_union_timing_profile.hpp             |  2 +-
 25 files changed, 43 insertions(+), 43 deletions(-)

diff --git a/cpp/src/cpc_sketch_timing_profile.cpp b/cpp/src/cpc_sketch_timing_profile.cpp
index 303bba5..d33a14d 100644
--- a/cpp/src/cpc_sketch_timing_profile.cpp
+++ b/cpp/src/cpc_sketch_timing_profile.cpp
@@ -29,7 +29,7 @@
 
 namespace datasketches {
 
-void cpc_sketch_timing_profile::run() const {
+void cpc_sketch_timing_profile::run() {
   const size_t lg_min_stream_len(0);
   const size_t lg_max_stream_len(23);
   const size_t ppo(16);
diff --git a/cpp/src/cpc_sketch_timing_profile.hpp b/cpp/src/cpc_sketch_timing_profile.hpp
index 6ccbe9e..db3d039 100644
--- a/cpp/src/cpc_sketch_timing_profile.hpp
+++ b/cpp/src/cpc_sketch_timing_profile.hpp
@@ -26,7 +26,7 @@ namespace datasketches {
 
 class cpc_sketch_timing_profile: public job_profile {
 public:
-  void run() const;
+  void run();
 };
 
 }
diff --git a/cpp/src/cpc_union_timing_profile.cpp b/cpp/src/cpc_union_timing_profile.cpp
index b1c65c3..380888a 100644
--- a/cpp/src/cpc_union_timing_profile.cpp
+++ b/cpp/src/cpc_union_timing_profile.cpp
@@ -29,7 +29,7 @@
 
 namespace datasketches {
 
-void cpc_union_timing_profile::run() const {
+void cpc_union_timing_profile::run() {
   const size_t lg_min_stream_len = 0;
   const size_t lg_max_stream_len = 26;
   const size_t ppo = 16;
diff --git a/cpp/src/cpc_union_timing_profile.hpp b/cpp/src/cpc_union_timing_profile.hpp
index d6525c3..0ad98eb 100644
--- a/cpp/src/cpc_union_timing_profile.hpp
+++ b/cpp/src/cpc_union_timing_profile.hpp
@@ -26,7 +26,7 @@ namespace datasketches {
 
 class cpc_union_timing_profile: public job_profile {
 public:
-  void run() const;
+  void run();
 };
 
 }
diff --git a/cpp/src/frequent_items_sketch_accuracy_profile.cpp b/cpp/src/frequent_items_sketch_accuracy_profile.cpp
index c89a79e..64b5b5a 100644
--- a/cpp/src/frequent_items_sketch_accuracy_profile.cpp
+++ b/cpp/src/frequent_items_sketch_accuracy_profile.cpp
@@ -27,7 +27,7 @@
 
 namespace datasketches {
 
-void frequent_items_sketch_accuracy_profile::run() const {
+void frequent_items_sketch_accuracy_profile::run() {
   const unsigned lg_num_sketches = 4; // merge if > 0 (more than 1 sketch)
 
   const unsigned lg_min_stream_len = 5;
diff --git a/cpp/src/frequent_items_sketch_accuracy_profile.hpp b/cpp/src/frequent_items_sketch_accuracy_profile.hpp
index b338cba..bb819e1 100644
--- a/cpp/src/frequent_items_sketch_accuracy_profile.hpp
+++ b/cpp/src/frequent_items_sketch_accuracy_profile.hpp
@@ -26,7 +26,7 @@ namespace datasketches {
 
 class frequent_items_sketch_accuracy_profile: public job_profile {
 public:
-  void run() const;
+  void run();
 };
 
 }
diff --git a/cpp/src/frequent_items_sketch_timing_profile.cpp b/cpp/src/frequent_items_sketch_timing_profile.cpp
index 42f53b7..6324da3 100644
--- a/cpp/src/frequent_items_sketch_timing_profile.cpp
+++ b/cpp/src/frequent_items_sketch_timing_profile.cpp
@@ -43,7 +43,7 @@ struct hash_long_long {
 };
 typedef frequent_items_sketch<long long, hash_long_long> frequent_longs_sketch;
 
-void frequent_items_sketch_timing_profile::run() const {
+void frequent_items_sketch_timing_profile::run() {
   const unsigned lg_min_stream_len = 0;
   const unsigned lg_max_stream_len = 23;
   const unsigned ppo = 16;
diff --git a/cpp/src/frequent_items_sketch_timing_profile.hpp b/cpp/src/frequent_items_sketch_timing_profile.hpp
index c7e7fcd..63290db 100644
--- a/cpp/src/frequent_items_sketch_timing_profile.hpp
+++ b/cpp/src/frequent_items_sketch_timing_profile.hpp
@@ -26,7 +26,7 @@ namespace datasketches {
 
 class frequent_items_sketch_timing_profile: public job_profile {
 public:
-  void run() const;
+  void run();
 };
 
 }
diff --git a/cpp/src/hll_union_timing_profile.cpp b/cpp/src/hll_union_timing_profile.cpp
index df5c939..e7f16f4 100644
--- a/cpp/src/hll_union_timing_profile.cpp
+++ b/cpp/src/hll_union_timing_profile.cpp
@@ -29,7 +29,7 @@
 
 namespace datasketches {
 
-void hll_union_timing_profile::run() const {
+void hll_union_timing_profile::run() {
   const size_t lg_min_stream_len = 0;
   const size_t lg_max_stream_len = 26;
   const size_t ppo = 16;
diff --git a/cpp/src/hll_union_timing_profile.hpp b/cpp/src/hll_union_timing_profile.hpp
index e1d85eb..5d73dd6 100644
--- a/cpp/src/hll_union_timing_profile.hpp
+++ b/cpp/src/hll_union_timing_profile.hpp
@@ -26,7 +26,7 @@ namespace datasketches {
 
 class hll_union_timing_profile: public job_profile {
 public:
-  void run() const;
+  void run();
 };
 
 }
diff --git a/cpp/src/job_profile.cpp b/cpp/src/job_profile.cpp
index 09851df..341b003 100644
--- a/cpp/src/job_profile.cpp
+++ b/cpp/src/job_profile.cpp
@@ -30,7 +30,7 @@ void job_profile::add(const char* name, std::unique_ptr<job_profile> profile) {
    registry[name] = std::move(profile);
 }
 
-const job_profile& job_profile::instance(const char* name) {
+job_profile& job_profile::instance(const char* name) {
   auto profile = registry.find(name);
   if (profile == registry.end()) throw std::invalid_argument("profile not found");
    return *profile->second;
@@ -58,11 +58,11 @@ const job_profile& job_profile::instance(const char* name) {
  * returns the next point in the power series.
  */
 size_t job_profile::pwr_2_law_next(size_t ppo, size_t cur_point) {
-  const size_t cur((cur_point < 1) ? 1 : cur_point);
-  size_t gi(round(log2(cur) * ppo)); //current generating index
+  const size_t cur = (cur_point < 1) ? 1 : cur_point;
+  size_t gi = round(log2(cur) * ppo); //current generating index
   size_t next;
   do {
-    next = round(pow(2.0, (double) ++gi / ppo));
+    next = round(pow(2.0, static_cast<double>(++gi) / ppo));
   } while (next <= cur_point);
   return next;
 }
@@ -76,9 +76,9 @@ size_t job_profile::pwr_2_law_next(size_t ppo, size_t cur_point) {
  * returns the actual number of plotting points between lgStart and lgEnd.
  */
 size_t job_profile::count_points(size_t lg_start, size_t lg_end, size_t ppo) {
-  size_t p(1 << lg_start);
-  const size_t end(1 << lg_end);
-  size_t count(0);
+  size_t p = 1 << lg_start;
+  const size_t end = 1 << lg_end;
+  size_t count = 0;
   while (p <= end) {
     p = pwr_2_law_next(ppo, p);
     count++;
diff --git a/cpp/src/job_profile.hpp b/cpp/src/job_profile.hpp
index 6b171f7..199308d 100644
--- a/cpp/src/job_profile.hpp
+++ b/cpp/src/job_profile.hpp
@@ -31,9 +31,9 @@ public:
    virtual ~job_profile() {}
 
    static void add(const char* name, std::unique_ptr<job_profile> profile);
-   static const job_profile& instance(const char* name);
+   static job_profile& instance(const char* name);
 
-   virtual void run() const = 0;
+   virtual void run() = 0;
 
    static size_t pwr_2_law_next(size_t ppo, size_t cur_point);
    static size_t count_points(size_t lg_start, size_t lg_end, size_t ppo);
diff --git a/cpp/src/kll_accuracy_profile.cpp b/cpp/src/kll_accuracy_profile.cpp
index 10c57b1..9e93a32 100644
--- a/cpp/src/kll_accuracy_profile.cpp
+++ b/cpp/src/kll_accuracy_profile.cpp
@@ -25,20 +25,20 @@
 
 namespace datasketches {
 
-void kll_accuracy_profile::run() const {
-  const unsigned lg_min(0);
-  const unsigned lg_max(23);
-  const unsigned ppo(16);
-  const unsigned num_trials(100);
-  const unsigned error_pct(99);
+void kll_accuracy_profile::run() {
+  const unsigned lg_min = 0;
+  const unsigned lg_max = 23;
+  const unsigned ppo = 16;
+  const unsigned num_trials = 100;
+  const unsigned error_pct = 99;
 
   double rank_errors[num_trials];
 
-  unsigned max_len(1 << lg_max);
+  unsigned max_len = 1 << lg_max;
   float* values = new float[max_len];
 
   const unsigned num_steps = count_points(lg_min, lg_max, ppo);
-  unsigned stream_length(1 << lg_min);
+  unsigned stream_length = 1 << lg_min;
   for (unsigned i = 0; i < num_steps; i++) {
     for (unsigned i = 0; i < stream_length; i++) values[i] = i;
 
diff --git a/cpp/src/kll_accuracy_profile.hpp b/cpp/src/kll_accuracy_profile.hpp
index 77c0021..96256c8 100644
--- a/cpp/src/kll_accuracy_profile.hpp
+++ b/cpp/src/kll_accuracy_profile.hpp
@@ -26,8 +26,8 @@ namespace datasketches {
 
 class kll_accuracy_profile: public job_profile {
 public:
-  void run() const;
-  virtual double run_trial(float* values, unsigned stream_length) const = 0;
+  void run();
+  virtual double run_trial(float* values, unsigned stream_length) = 0;
 };
 
 }
diff --git a/cpp/src/kll_merge_accuracy_profile.cpp b/cpp/src/kll_merge_accuracy_profile.cpp
index e0bae4f..65db044 100644
--- a/cpp/src/kll_merge_accuracy_profile.cpp
+++ b/cpp/src/kll_merge_accuracy_profile.cpp
@@ -27,17 +27,17 @@
 
 namespace datasketches {
 
-double kll_merge_accuracy_profile::run_trial(float* values, unsigned stream_length) const {
+double kll_merge_accuracy_profile::run_trial(float* values, unsigned stream_length) {
   unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
   std::shuffle(values, values + stream_length, std::default_random_engine(seed));
 
-  const unsigned num_sketches(8);
+  const unsigned num_sketches = 8;
   std::unique_ptr<kll_sketch<float>> sketches[num_sketches];
   for (unsigned i = 0; i < num_sketches; i++) {
     sketches[i] = std::unique_ptr<kll_sketch<float>>(new kll_sketch<float>());
   }
 
-  unsigned j(0);
+  unsigned j = 0;
   for (size_t i = 0; i < stream_length; i++) {
     sketches[j]->update(values[i]);
     j++;
@@ -49,7 +49,7 @@ double kll_merge_accuracy_profile::run_trial(float* values, unsigned stream_leng
 
   double max_rank_error = 0;
   for (size_t i = 0; i < stream_length; i++) {
-    double true_rank = (double) i / stream_length;
+    double true_rank = static_cast<double>(i) / stream_length;
     double est_rank = sketch.get_rank(i);
     max_rank_error = std::max(max_rank_error, abs(true_rank - est_rank));
   }
diff --git a/cpp/src/kll_merge_accuracy_profile.hpp b/cpp/src/kll_merge_accuracy_profile.hpp
index b0c1b8d..210c692 100644
--- a/cpp/src/kll_merge_accuracy_profile.hpp
+++ b/cpp/src/kll_merge_accuracy_profile.hpp
@@ -26,7 +26,7 @@ namespace datasketches {
 
 class kll_merge_accuracy_profile: public kll_accuracy_profile {
 public:
-  double run_trial(float* values, unsigned stream_length) const;
+  double run_trial(float* values, unsigned stream_length);
 };
 
 }
diff --git a/cpp/src/kll_sketch_accuracy_profile.cpp b/cpp/src/kll_sketch_accuracy_profile.cpp
index b1f3c4e..2caa3e2 100644
--- a/cpp/src/kll_sketch_accuracy_profile.cpp
+++ b/cpp/src/kll_sketch_accuracy_profile.cpp
@@ -27,7 +27,7 @@
 
 namespace datasketches {
 
-double kll_sketch_accuracy_profile::run_trial(float* values, unsigned stream_length) const {
+double kll_sketch_accuracy_profile::run_trial(float* values, unsigned stream_length) {
   unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
   std::shuffle(values, values + stream_length, std::default_random_engine(seed));
 
diff --git a/cpp/src/kll_sketch_accuracy_profile.hpp b/cpp/src/kll_sketch_accuracy_profile.hpp
index 0fd7695..ded6ef5 100644
--- a/cpp/src/kll_sketch_accuracy_profile.hpp
+++ b/cpp/src/kll_sketch_accuracy_profile.hpp
@@ -26,7 +26,7 @@ namespace datasketches {
 
 class kll_sketch_accuracy_profile: public kll_accuracy_profile {
 public:
-  double run_trial(float* values, unsigned stream_length) const;
+  double run_trial(float* values, unsigned stream_length);
 };
 
 }
diff --git a/cpp/src/kll_sketch_timing_profile.cpp b/cpp/src/kll_sketch_timing_profile.cpp
index 60c88ea..df5d8ab 100644
--- a/cpp/src/kll_sketch_timing_profile.cpp
+++ b/cpp/src/kll_sketch_timing_profile.cpp
@@ -29,7 +29,7 @@
 
 namespace datasketches {
 
-void kll_sketch_timing_profile::run() const {
+void kll_sketch_timing_profile::run() {
   const size_t lg_min_stream_len(0);
   const size_t lg_max_stream_len(23);
   const size_t ppo(16);
diff --git a/cpp/src/kll_sketch_timing_profile.hpp b/cpp/src/kll_sketch_timing_profile.hpp
index c7872c2..3f41efe 100644
--- a/cpp/src/kll_sketch_timing_profile.hpp
+++ b/cpp/src/kll_sketch_timing_profile.hpp
@@ -26,7 +26,7 @@ namespace datasketches {
 
 class kll_sketch_timing_profile: public job_profile {
 public:
-  void run() const;
+  void run();
 };
 
 }
diff --git a/cpp/src/main.cpp b/cpp/src/main.cpp
index e9027c4..b92c8b0 100644
--- a/cpp/src/main.cpp
+++ b/cpp/src/main.cpp
@@ -52,7 +52,7 @@ int main(int argc, char **argv) {
   job_profile::add("fi-accuracy", job_profile_ptr(new frequent_items_sketch_accuracy_profile()));
 
   if (argc == 2) {
-    const datasketches::job_profile& profile = datasketches::job_profile::instance(argv[1]);
+    datasketches::job_profile& profile = datasketches::job_profile::instance(argv[1]);
     profile.run();
   } else {
     std::cerr << "One parameter expected: profile name" << std::endl;
diff --git a/cpp/src/theta_sketch_timing_profile.cpp b/cpp/src/theta_sketch_timing_profile.cpp
index f0f5ed9..b882091 100644
--- a/cpp/src/theta_sketch_timing_profile.cpp
+++ b/cpp/src/theta_sketch_timing_profile.cpp
@@ -29,7 +29,7 @@
 
 namespace datasketches {
 
-void theta_sketch_timing_profile::run() const {
+void theta_sketch_timing_profile::run() {
   const size_t lg_min_stream_len(0);
   const size_t lg_max_stream_len(23);
   const size_t ppo(16);
diff --git a/cpp/src/theta_sketch_timing_profile.hpp b/cpp/src/theta_sketch_timing_profile.hpp
index 88e3551..6995520 100644
--- a/cpp/src/theta_sketch_timing_profile.hpp
+++ b/cpp/src/theta_sketch_timing_profile.hpp
@@ -26,7 +26,7 @@ namespace datasketches {
 
 class theta_sketch_timing_profile: public job_profile {
 public:
-  void run() const;
+  void run();
 };
 
 }
diff --git a/cpp/src/theta_union_timing_profile.cpp b/cpp/src/theta_union_timing_profile.cpp
index 7a3fd8c..6404545 100644
--- a/cpp/src/theta_union_timing_profile.cpp
+++ b/cpp/src/theta_union_timing_profile.cpp
@@ -29,7 +29,7 @@
 
 namespace datasketches {
 
-void theta_union_timing_profile::run() const {
+void theta_union_timing_profile::run() {
   const size_t lg_min_stream_len = 0;
   const size_t lg_max_stream_len = 26;
   const size_t ppo = 16;
diff --git a/cpp/src/theta_union_timing_profile.hpp b/cpp/src/theta_union_timing_profile.hpp
index 0663794..0bb229f 100644
--- a/cpp/src/theta_union_timing_profile.hpp
+++ b/cpp/src/theta_union_timing_profile.hpp
@@ -26,7 +26,7 @@ namespace datasketches {
 
 class theta_union_timing_profile: public job_profile {
 public:
-  void run() const;
+  void run();
 };
 
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org