[Groonga-commit] groonga/grnxx at 7515861 [master] Split benchmark_filter into benchmark_filter_and/or.

Back to archive index

susumu.yata null+****@clear*****
Wed Dec 3 15:03:52 JST 2014


susumu.yata	2014-12-03 15:03:52 +0900 (Wed, 03 Dec 2014)

  New Revision: 7515861f40e29b6a787a469cdb7d0e707e8df5c0
  https://github.com/groonga/grnxx/commit/7515861f40e29b6a787a469cdb7d0e707e8df5c0

  Message:
    Split benchmark_filter into benchmark_filter_and/or.

  Copied files:
    benchmark/benchmark_filter_and.cpp
      (from benchmark/benchmark_filter.cpp)
  Modified files:
    .gitignore
    benchmark/Makefile.am
  Renamed files:
    benchmark/benchmark_filter_or.cpp
      (from benchmark/benchmark_filter.cpp)

  Modified: .gitignore (+2 -1)
===================================================================
--- .gitignore    2014-12-03 14:56:27 +0900 (fbf0bf1)
+++ .gitignore    2014-12-03 15:03:52 +0900 (1be5b69)
@@ -17,7 +17,8 @@ aclocal.m4
 autom4te.cache/
 benchmark/*.trs
 benchmark/benchmark_adjuster
-benchmark/benchmark_filter
+benchmark/benchmark_filter_and
+benchmark/benchmark_filter_or
 benchmark/benchmark_sorter
 compile
 config.*

  Modified: benchmark/Makefile.am (+7 -3)
===================================================================
--- benchmark/Makefile.am    2014-12-03 14:56:27 +0900 (2918cd8)
+++ benchmark/Makefile.am    2014-12-03 15:03:52 +0900 (f1e3aaa)
@@ -1,11 +1,15 @@
 noinst_PROGRAMS =		\
-	benchmark_filter
+	benchmark_filter_and	\
+	benchmark_filter_or
 
 #	benchmark_adjuster	\
 #	benchmark_sorter
 
-benchmark_filter_SOURCES = benchmark_filter.cpp
-benchmark_filter_LDADD = $(top_srcdir)/lib/grnxx/libgrnxx.la
+benchmark_filter_and_SOURCES = benchmark_filter_and.cpp
+benchmark_filter_and_LDADD = $(top_srcdir)/lib/grnxx/libgrnxx.la
+
+benchmark_filter_or_SOURCES = benchmark_filter_or.cpp
+benchmark_filter_or_LDADD = $(top_srcdir)/lib/grnxx/libgrnxx.la
 
 #benchmark_adjuster_SOURCES = benchmark_adjuster.cpp
 #benchmark_adjuster_LDADD = $(top_srcdir)/lib/grnxx/libgrnxx.la

  Copied: benchmark/benchmark_filter_and.cpp (+16 -161) 53%
===================================================================
--- benchmark/benchmark_filter.cpp    2014-12-03 14:56:27 +0900 (d9082e6)
+++ benchmark/benchmark_filter_and.cpp    2014-12-03 15:03:52 +0900 (a8c2772)
@@ -65,54 +65,6 @@ void generate_data() {
   }
 }
 
-void benchmark_grnxx_not_and(const grnxx::Table *table,
-                             grnxx::Int upper_limit) {
-  std::cout << "LOGICAL_NOT/AND: ";
-  std::cout << "ratio = " << (100 * upper_limit.raw() / 256) << '%';
-  double min_elapsed = std::numeric_limits<double>::max();
-  for (size_t i = 0; i < LOOP; ++i) {
-    Timer timer;
-
-    auto pipeline_builder = grnxx::PipelineBuilder::create(table);
-    auto cursor = table->create_cursor();
-    pipeline_builder->push_cursor(std::move(cursor));
-    auto expression_builder = grnxx::ExpressionBuilder::create(table);
-    expression_builder->push_column("A");
-    expression_builder->push_constant(upper_limit);
-    expression_builder->push_operator(grnxx::GREATER_EQUAL_OPERATOR);
-    expression_builder->push_column("B");
-    expression_builder->push_constant(upper_limit);
-    expression_builder->push_operator(grnxx::GREATER_EQUAL_OPERATOR);
-    expression_builder->push_column("C");
-    expression_builder->push_constant(upper_limit);
-    expression_builder->push_operator(grnxx::GREATER_EQUAL_OPERATOR);
-    expression_builder->push_operator(grnxx::LOGICAL_AND_OPERATOR);
-    expression_builder->push_operator(grnxx::LOGICAL_AND_OPERATOR);
-    expression_builder->push_operator(grnxx::LOGICAL_NOT_OPERATOR);
-    auto expression = expression_builder->release();
-    pipeline_builder->push_filter(std::move(expression));
-    auto pipeline = pipeline_builder->release();
-    grnxx::Array<grnxx::Record> records;
-    pipeline->flush(&records);
-
-    double elapsed = timer.elapsed();
-    if (elapsed < min_elapsed) {
-      min_elapsed = elapsed;
-    }
-  }
-  std::cout << ", min. elapsed [s] = " << min_elapsed << std::endl;
-}
-
-void benchmark_grnxx_not_and(const grnxx::Table *table) {
-  benchmark_grnxx_not_and(table, grnxx::Int(16));
-  benchmark_grnxx_not_and(table, grnxx::Int(32));
-  benchmark_grnxx_not_and(table, grnxx::Int(64));
-  benchmark_grnxx_not_and(table, grnxx::Int(128));
-  benchmark_grnxx_not_and(table, grnxx::Int(192));
-  benchmark_grnxx_not_and(table, grnxx::Int(224));
-  benchmark_grnxx_not_and(table, grnxx::Int(240));
-}
-
 void benchmark_grnxx(const grnxx::Table *table,
                      grnxx::OperatorType logical_operator_type,
                      grnxx::Int upper_limit) {
@@ -121,18 +73,10 @@ void benchmark_grnxx(const grnxx::Table *table,
       std::cout << "LOGICAL_AND: ";
       break;
     }
-    case grnxx::LOGICAL_OR_OPERATOR: {
-      std::cout << "LOGICAL_OR: ";
-      break;
-    }
     case grnxx::BITWISE_AND_OPERATOR: {
       std::cout << "BITWISE_AND: ";
       break;
     }
-    case grnxx::BITWISE_OR_OPERATOR: {
-      std::cout << "BITWISE_OR: ";
-      break;
-    }
     default: {
       break;
     }
@@ -198,13 +142,10 @@ void benchmark_grnxx() {
   }
 
   benchmark_grnxx(table, grnxx::LOGICAL_AND_OPERATOR);
-  benchmark_grnxx(table, grnxx::LOGICAL_OR_OPERATOR);
   benchmark_grnxx(table, grnxx::BITWISE_AND_OPERATOR);
-  benchmark_grnxx(table, grnxx::BITWISE_OR_OPERATOR);
-  benchmark_grnxx_not_and(table);
 }
 
-void benchmark_native_batch_and(grnxx::Int upper_limit) {
+void benchmark_native_batch(grnxx::Int upper_limit) {
   std::cout << "LOGICAL_AND: ";
   std::cout << "ratio = " << (100 * upper_limit.raw() / 256) << '%';
   double min_elapsed = std::numeric_limits<double>::max();
@@ -236,66 +177,19 @@ void benchmark_native_batch_and(grnxx::Int upper_limit) {
   std::cout << ", min. elapsed [s] = " << min_elapsed << std::endl;
 }
 
-void benchmark_native_batch_and() {
-  benchmark_native_batch_and(grnxx::Int(16));
-  benchmark_native_batch_and(grnxx::Int(32));
-  benchmark_native_batch_and(grnxx::Int(64));
-  benchmark_native_batch_and(grnxx::Int(128));
-  benchmark_native_batch_and(grnxx::Int(192));
-  benchmark_native_batch_and(grnxx::Int(224));
-  benchmark_native_batch_and(grnxx::Int(240));
-}
-
-void benchmark_native_batch_or(grnxx::Int upper_limit) {
-  std::cout << "LOGICAL_OR: ";
-  std::cout << "ratio = " << (100 * upper_limit.raw() / 256) << '%';
-  double min_elapsed = std::numeric_limits<double>::max();
-  for (size_t i = 0; i < LOOP; ++i) {
-    Timer timer;
-
-    grnxx::Array<grnxx::Record> records;
-    records.resize(SIZE);
-    for (size_t j = 0; j < SIZE; ++j) {
-      records[j].row_id = grnxx::Int(j);
-      records[j].score = grnxx::Float(0.0);
-    }
-    size_t count = 0;
-    for (size_t j = 0; j < SIZE; ++j) {
-      if ((a[records[j].row_id.raw()] < upper_limit).is_true() ||
-          (b[records[j].row_id.raw()] < upper_limit).is_true() ||
-          (c[records[j].row_id.raw()] < upper_limit).is_true()) {
-        records[count] = grnxx::Record(grnxx::Int(j), grnxx::Float(0.0));
-        ++count;
-      }
-    }
-    records.resize(count);
-
-    double elapsed = timer.elapsed();
-    if (elapsed < min_elapsed) {
-      min_elapsed = elapsed;
-    }
-  }
-  std::cout << ", min. elapsed [s] = " << min_elapsed << std::endl;
-}
-
-void benchmark_native_batch_or() {
-  benchmark_native_batch_or(grnxx::Int(16));
-  benchmark_native_batch_or(grnxx::Int(32));
-  benchmark_native_batch_or(grnxx::Int(64));
-  benchmark_native_batch_or(grnxx::Int(128));
-  benchmark_native_batch_or(grnxx::Int(192));
-  benchmark_native_batch_or(grnxx::Int(224));
-  benchmark_native_batch_or(grnxx::Int(240));
-}
-
 void benchmark_native_batch() {
   std::cout << __PRETTY_FUNCTION__ << std::endl;
 
-  benchmark_native_batch_and();
-  benchmark_native_batch_or();
+  benchmark_native_batch(grnxx::Int(16));
+  benchmark_native_batch(grnxx::Int(32));
+  benchmark_native_batch(grnxx::Int(64));
+  benchmark_native_batch(grnxx::Int(128));
+  benchmark_native_batch(grnxx::Int(192));
+  benchmark_native_batch(grnxx::Int(224));
+  benchmark_native_batch(grnxx::Int(240));
 }
 
-void benchmark_native_sequential_and(grnxx::Int upper_limit) {
+void benchmark_native_sequential(grnxx::Int upper_limit) {
   std::cout << "LOGICAL_AND: ";
   std::cout << "ratio = " << (100 * upper_limit.raw() / 256) << '%';
   double min_elapsed = std::numeric_limits<double>::max();
@@ -319,55 +213,16 @@ void benchmark_native_sequential_and(grnxx::Int upper_limit) {
   std::cout << ", min. elapsed [s] = " << min_elapsed << std::endl;
 }
 
-void benchmark_native_sequential_and() {
-  benchmark_native_sequential_and(grnxx::Int(16));
-  benchmark_native_sequential_and(grnxx::Int(32));
-  benchmark_native_sequential_and(grnxx::Int(64));
-  benchmark_native_sequential_and(grnxx::Int(128));
-  benchmark_native_sequential_and(grnxx::Int(192));
-  benchmark_native_sequential_and(grnxx::Int(224));
-  benchmark_native_sequential_and(grnxx::Int(240));
-}
-
-void benchmark_native_sequential_or(grnxx::Int upper_limit) {
-  std::cout << "LOGICAL_OR: ";
-  std::cout << "ratio = " << (100 * upper_limit.raw() / 256) << '%';
-  double min_elapsed = std::numeric_limits<double>::max();
-  for (size_t i = 0; i < LOOP; ++i) {
-    Timer timer;
-
-    grnxx::Array<grnxx::Record> records;
-    for (size_t j = 0; j < SIZE; ++j) {
-      if ((a[j] < upper_limit).is_true() ||
-          (b[j] < upper_limit).is_true() ||
-          (c[j] < upper_limit).is_true()) {
-        records.push_back(grnxx::Record(grnxx::Int(j), grnxx::Float(0.0)));
-      }
-    }
-
-    double elapsed = timer.elapsed();
-    if (elapsed < min_elapsed) {
-      min_elapsed = elapsed;
-    }
-  }
-  std::cout << ", min. elapsed [s] = " << min_elapsed << std::endl;
-}
-
-void benchmark_native_sequential_or() {
-  benchmark_native_sequential_or(grnxx::Int(16));
-  benchmark_native_sequential_or(grnxx::Int(32));
-  benchmark_native_sequential_or(grnxx::Int(64));
-  benchmark_native_sequential_or(grnxx::Int(128));
-  benchmark_native_sequential_or(grnxx::Int(192));
-  benchmark_native_sequential_or(grnxx::Int(224));
-  benchmark_native_sequential_or(grnxx::Int(240));
-}
-
 void benchmark_native_sequential() {
   std::cout << __PRETTY_FUNCTION__ << std::endl;
 
-  benchmark_native_sequential_and();
-  benchmark_native_sequential_or();
+  benchmark_native_sequential(grnxx::Int(16));
+  benchmark_native_sequential(grnxx::Int(32));
+  benchmark_native_sequential(grnxx::Int(64));
+  benchmark_native_sequential(grnxx::Int(128));
+  benchmark_native_sequential(grnxx::Int(192));
+  benchmark_native_sequential(grnxx::Int(224));
+  benchmark_native_sequential(grnxx::Int(240));
 }
 
 void benchmark_native() {

  Renamed: benchmark/benchmark_filter_or.cpp (+16 -112) 69%
===================================================================
--- benchmark/benchmark_filter.cpp    2014-12-03 14:56:27 +0900 (d9082e6)
+++ benchmark/benchmark_filter_or.cpp    2014-12-03 15:03:52 +0900 (96c55e9)
@@ -117,18 +117,10 @@ void benchmark_grnxx(const grnxx::Table *table,
                      grnxx::OperatorType logical_operator_type,
                      grnxx::Int upper_limit) {
   switch (logical_operator_type) {
-    case grnxx::LOGICAL_AND_OPERATOR: {
-      std::cout << "LOGICAL_AND: ";
-      break;
-    }
     case grnxx::LOGICAL_OR_OPERATOR: {
       std::cout << "LOGICAL_OR: ";
       break;
     }
-    case grnxx::BITWISE_AND_OPERATOR: {
-      std::cout << "BITWISE_AND: ";
-      break;
-    }
     case grnxx::BITWISE_OR_OPERATOR: {
       std::cout << "BITWISE_OR: ";
       break;
@@ -197,56 +189,12 @@ void benchmark_grnxx() {
     col_c->set(row_id, c[i]);
   }
 
-  benchmark_grnxx(table, grnxx::LOGICAL_AND_OPERATOR);
   benchmark_grnxx(table, grnxx::LOGICAL_OR_OPERATOR);
-  benchmark_grnxx(table, grnxx::BITWISE_AND_OPERATOR);
   benchmark_grnxx(table, grnxx::BITWISE_OR_OPERATOR);
   benchmark_grnxx_not_and(table);
 }
 
-void benchmark_native_batch_and(grnxx::Int upper_limit) {
-  std::cout << "LOGICAL_AND: ";
-  std::cout << "ratio = " << (100 * upper_limit.raw() / 256) << '%';
-  double min_elapsed = std::numeric_limits<double>::max();
-  for (size_t i = 0; i < LOOP; ++i) {
-    Timer timer;
-
-    grnxx::Array<grnxx::Record> records;
-    records.resize(SIZE);
-    for (size_t j = 0; j < SIZE; ++j) {
-      records[j].row_id = grnxx::Int(j);
-      records[j].score = grnxx::Float(0.0);
-    }
-    size_t count = 0;
-    for (size_t j = 0; j < SIZE; ++j) {
-      if ((a[records[j].row_id.raw()] < upper_limit).is_true() &&
-          (b[records[j].row_id.raw()] < upper_limit).is_true() &&
-          (c[records[j].row_id.raw()] < upper_limit).is_true()) {
-        records[count] = grnxx::Record(grnxx::Int(j), grnxx::Float(0.0));
-        ++count;
-      }
-    }
-    records.resize(count);
-
-    double elapsed = timer.elapsed();
-    if (elapsed < min_elapsed) {
-      min_elapsed = elapsed;
-    }
-  }
-  std::cout << ", min. elapsed [s] = " << min_elapsed << std::endl;
-}
-
-void benchmark_native_batch_and() {
-  benchmark_native_batch_and(grnxx::Int(16));
-  benchmark_native_batch_and(grnxx::Int(32));
-  benchmark_native_batch_and(grnxx::Int(64));
-  benchmark_native_batch_and(grnxx::Int(128));
-  benchmark_native_batch_and(grnxx::Int(192));
-  benchmark_native_batch_and(grnxx::Int(224));
-  benchmark_native_batch_and(grnxx::Int(240));
-}
-
-void benchmark_native_batch_or(grnxx::Int upper_limit) {
+void benchmark_native_batch(grnxx::Int upper_limit) {
   std::cout << "LOGICAL_OR: ";
   std::cout << "ratio = " << (100 * upper_limit.raw() / 256) << '%';
   double min_elapsed = std::numeric_limits<double>::max();
@@ -278,58 +226,19 @@ void benchmark_native_batch_or(grnxx::Int upper_limit) {
   std::cout << ", min. elapsed [s] = " << min_elapsed << std::endl;
 }
 
-void benchmark_native_batch_or() {
-  benchmark_native_batch_or(grnxx::Int(16));
-  benchmark_native_batch_or(grnxx::Int(32));
-  benchmark_native_batch_or(grnxx::Int(64));
-  benchmark_native_batch_or(grnxx::Int(128));
-  benchmark_native_batch_or(grnxx::Int(192));
-  benchmark_native_batch_or(grnxx::Int(224));
-  benchmark_native_batch_or(grnxx::Int(240));
-}
-
 void benchmark_native_batch() {
   std::cout << __PRETTY_FUNCTION__ << std::endl;
 
-  benchmark_native_batch_and();
-  benchmark_native_batch_or();
-}
-
-void benchmark_native_sequential_and(grnxx::Int upper_limit) {
-  std::cout << "LOGICAL_AND: ";
-  std::cout << "ratio = " << (100 * upper_limit.raw() / 256) << '%';
-  double min_elapsed = std::numeric_limits<double>::max();
-  for (size_t i = 0; i < LOOP; ++i) {
-    Timer timer;
-
-    grnxx::Array<grnxx::Record> records;
-    for (size_t j = 0; j < SIZE; ++j) {
-      if ((a[j] < upper_limit).is_true() &&
-          (b[j] < upper_limit).is_true() &&
-          (c[j] < upper_limit).is_true()) {
-        records.push_back(grnxx::Record(grnxx::Int(j), grnxx::Float(0.0)));
-      }
-    }
-
-    double elapsed = timer.elapsed();
-    if (elapsed < min_elapsed) {
-      min_elapsed = elapsed;
-    }
-  }
-  std::cout << ", min. elapsed [s] = " << min_elapsed << std::endl;
+  benchmark_native_batch(grnxx::Int(16));
+  benchmark_native_batch(grnxx::Int(32));
+  benchmark_native_batch(grnxx::Int(64));
+  benchmark_native_batch(grnxx::Int(128));
+  benchmark_native_batch(grnxx::Int(192));
+  benchmark_native_batch(grnxx::Int(224));
+  benchmark_native_batch(grnxx::Int(240));
 }
 
-void benchmark_native_sequential_and() {
-  benchmark_native_sequential_and(grnxx::Int(16));
-  benchmark_native_sequential_and(grnxx::Int(32));
-  benchmark_native_sequential_and(grnxx::Int(64));
-  benchmark_native_sequential_and(grnxx::Int(128));
-  benchmark_native_sequential_and(grnxx::Int(192));
-  benchmark_native_sequential_and(grnxx::Int(224));
-  benchmark_native_sequential_and(grnxx::Int(240));
-}
-
-void benchmark_native_sequential_or(grnxx::Int upper_limit) {
+void benchmark_native_sequential(grnxx::Int upper_limit) {
   std::cout << "LOGICAL_OR: ";
   std::cout << "ratio = " << (100 * upper_limit.raw() / 256) << '%';
   double min_elapsed = std::numeric_limits<double>::max();
@@ -353,21 +262,16 @@ void benchmark_native_sequential_or(grnxx::Int upper_limit) {
   std::cout << ", min. elapsed [s] = " << min_elapsed << std::endl;
 }
 
-void benchmark_native_sequential_or() {
-  benchmark_native_sequential_or(grnxx::Int(16));
-  benchmark_native_sequential_or(grnxx::Int(32));
-  benchmark_native_sequential_or(grnxx::Int(64));
-  benchmark_native_sequential_or(grnxx::Int(128));
-  benchmark_native_sequential_or(grnxx::Int(192));
-  benchmark_native_sequential_or(grnxx::Int(224));
-  benchmark_native_sequential_or(grnxx::Int(240));
-}
-
 void benchmark_native_sequential() {
   std::cout << __PRETTY_FUNCTION__ << std::endl;
 
-  benchmark_native_sequential_and();
-  benchmark_native_sequential_or();
+  benchmark_native_sequential(grnxx::Int(16));
+  benchmark_native_sequential(grnxx::Int(32));
+  benchmark_native_sequential(grnxx::Int(64));
+  benchmark_native_sequential(grnxx::Int(128));
+  benchmark_native_sequential(grnxx::Int(192));
+  benchmark_native_sequential(grnxx::Int(224));
+  benchmark_native_sequential(grnxx::Int(240));
 }
 
 void benchmark_native() {
-------------- next part --------------
HTML����������������������������...
下载 



More information about the Groonga-commit mailing list
Back to archive index