$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r73396 - in sandbox/bloom_filter/trunk/libs/bloom_filter/benchmark: . detail
From: cpp.cabrera_at_[hidden]
Date: 2011-07-26 17:26:12
Author: alejandro
Date: 2011-07-26 17:26:11 EDT (Tue, 26 Jul 2011)
New Revision: 73396
URL: http://svn.boost.org/trac/boost/changeset/73396
Log:
Added a benchmark for dynamic_bloom_filter. It's preliminary. The benchmark procedure needs to be changed a bit, since this mostly tests memory-reallocation speed.
Added:
   sandbox/bloom_filter/trunk/libs/bloom_filter/benchmark/detail/dynamic_benchmark.hpp   (contents, props changed)
   sandbox/bloom_filter/trunk/libs/bloom_filter/benchmark/dynamic_bloom_insert.cpp   (contents, props changed)
Text files modified: 
   sandbox/bloom_filter/trunk/libs/bloom_filter/benchmark/.gitignore |     1 +                                       
   1 files changed, 1 insertions(+), 0 deletions(-)
Modified: sandbox/bloom_filter/trunk/libs/bloom_filter/benchmark/.gitignore
==============================================================================
--- sandbox/bloom_filter/trunk/libs/bloom_filter/benchmark/.gitignore	(original)
+++ sandbox/bloom_filter/trunk/libs/bloom_filter/benchmark/.gitignore	2011-07-26 17:26:11 EDT (Tue, 26 Jul 2011)
@@ -1,3 +1,4 @@
 bloom_insert
 stdhash_insert
 stdset_insert
+dynamic_bloom_insert
Added: sandbox/bloom_filter/trunk/libs/bloom_filter/benchmark/detail/dynamic_benchmark.hpp
==============================================================================
--- (empty file)
+++ sandbox/bloom_filter/trunk/libs/bloom_filter/benchmark/detail/dynamic_benchmark.hpp	2011-07-26 17:26:11 EDT (Tue, 26 Jul 2011)
@@ -0,0 +1,47 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Alejandro Cabrera 2011.
+// Distributed under the Boost
+// Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or
+// copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/bloom_filter for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#ifndef BOOST_DETAIL_DYNAMIC_BENCHMARK_HPP
+#define BOOST_DETAIL_DYNAMIC_BENCHMARK_HPP
+
+#include <boost/timer.hpp>
+#include <cstddef>
+
+namespace boost {
+  namespace detail {
+    template <typename T,
+	      size_t OpCount,
+	      class Generator,
+	      class Container>
+    class benchmark {
+    public:
+      explicit benchmark(const size_t size) :
+      container(size), test_time(0.0) {}
+
+      double time() const { return test_time; }
+
+      void run() {
+	boost::timer timer;
+	for (size_t i = 0; i < OpCount; ++i) {
+	  container.insert(gen());
+	}
+	test_time = timer.elapsed();
+      }
+
+    private:
+      Container container;
+      Generator gen;
+      double test_time;
+    };
+  }
+}
+#endif
Added: sandbox/bloom_filter/trunk/libs/bloom_filter/benchmark/dynamic_bloom_insert.cpp
==============================================================================
--- (empty file)
+++ sandbox/bloom_filter/trunk/libs/bloom_filter/benchmark/dynamic_bloom_insert.cpp	2011-07-26 17:26:11 EDT (Tue, 26 Jul 2011)
@@ -0,0 +1,49 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Alejandro Cabrera 2011.
+// Distributed under the Boost
+// Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or
+// copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/bloom_filter for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#include "detail/pow.hpp"
+#include "detail/generator.hpp"
+#include "detail/dynamic_benchmark.hpp"
+
+#include <boost/bloom_filter/dynamic_bloom_filter.hpp>
+#include <boost/progress.hpp>
+#include <iostream>
+using namespace std;
+using boost::detail::Pow;
+using boost::detail::benchmark;
+using boost::detail::generator;
+using boost::bloom_filters::dynamic_bloom_filter;
+
+int main()
+{
+  static const size_t REPEAT = Pow<10, 3>::val; // 1000 
+  static const size_t OPS = Pow<10, 6>::val; // 1,000,000 inserts
+  static const size_t BITS = Pow<2, 21>::val; // 2MB
+
+  boost::progress_display progress(REPEAT);
+  double total_time = 0.0;
+
+  for (size_t i = 0; i < REPEAT; ++i, ++progress) {
+    benchmark<int, OPS, 
+	      generator<int>,
+	      dynamic_bloom_filter<int> > bench(BITS);
+
+    bench.run();
+
+    total_time += bench.time();
+  }
+
+  cout << REPEAT << " trials of " << OPS << " insertions took " 
+       << total_time << " seconds" << endl;
+
+  return 0;
+}