|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r73021 - sandbox/bloom_filter/trunk/libs/bloom_filter/benchmark
From: cpp.cabrera_at_[hidden]
Date: 2011-07-12 15:43:18
Author: alejandro
Date: 2011-07-12 15:43:17 EDT (Tue, 12 Jul 2011)
New Revision: 73021
URL: http://svn.boost.org/trac/boost/changeset/73021
Log:
Added a benchamrk that compares the run-time and compile-time size of various data structures, including all current Bloom filters.
Added:
sandbox/bloom_filter/trunk/libs/bloom_filter/benchmark/meta_compare.cpp (contents, props changed)
Added: sandbox/bloom_filter/trunk/libs/bloom_filter/benchmark/meta_compare.cpp
==============================================================================
--- (empty file)
+++ sandbox/bloom_filter/trunk/libs/bloom_filter/benchmark/meta_compare.cpp 2011-07-12 15:43:17 EDT (Tue, 12 Jul 2011)
@@ -0,0 +1,58 @@
+#include <iostream>
+#include <boost/bloom_filter/bloom.hpp>
+#include <boost/bloom_filter/dynamic_bloom.hpp>
+#include <boost/bloom_filter/counting_bloom.hpp>
+#include <boost/unordered_set.hpp>
+#include <set>
+using boost::bloom_filter::bloom_filter;
+using boost::bloom_filter::dynamic_bloom_filter;
+using boost::bloom_filter::counting_bloom_filter;
+using boost::unordered_set;
+
+typedef bloom_filter<int, 1000> basic_bloom;
+typedef dynamic_bloom_filter<int> basic_dynamic_bloom;
+typedef counting_bloom_filter<int, 1000> counting_bloom;
+
+int main()
+{
+ basic_bloom basic;
+ basic_dynamic_bloom dynamic(1000);
+ counting_bloom counting;
+ boost::unordered_set<int> hash_set;
+ std::set<int> set;
+
+ std::cout << "\n============== Static size comparison ==============\n";
+
+ std::cout << "Basic Bloom filter static size: " << sizeof(basic_bloom) << "\n"
+ << "Basic dynamic Bloom filter static size: " << sizeof(basic_dynamic_bloom) << "\n"
+ << "Counting Bloom filter static size: " << sizeof(counting_bloom) << "\n"
+ << "Unordered set static size: " << sizeof(boost::unordered_set<int>) << "\n"
+ << "Set static size: " << sizeof(std::set<int>) << std::endl;
+
+ for (size_t i = 0; i < 1000; ++i) {
+ basic.insert(i);
+ dynamic.insert(i);
+ counting.insert(i);
+ hash_set.insert(i);
+ set.insert(i);
+ }
+
+ std::cout << "\n============== Run-time size comparison ==============\n";
+
+ std::cout << "Basic Bloom filter run-time size: " << 0 << "\n"
+ << "Basic dynamic Bloom filter run-time size: " << dynamic.bit_capacity() << "\n"
+ << "Counting Bloom filter run-time size: " << 0 << "\n"
+ << "Unordered set run-time size: " << sizeof(int) * hash_set.size() << " + X\n"
+ << "Set run-time size: " << sizeof(int) * set.size() << " + X" << std::endl;
+
+ std::cout << "\n============== Total size comparison ==============\n";
+
+ std::cout << "Basic Bloom filter total size: " << sizeof(basic_bloom) + 0 << "\n"
+ << "Basic dynamic Bloom filter total size: " << sizeof(basic_dynamic_bloom) + dynamic.bit_capacity() << "\n"
+ << "Counting Bloom filter total size: " << sizeof(counting_bloom) + 0 << "\n"
+ << "Unordered set total size: " << sizeof(boost::unordered_set<int>) + sizeof(int) * hash_set.size() << " + X\n"
+ << "Set total size: " << sizeof(std::set<int>) + sizeof(int) * set.size() << " + X" << std::endl;
+
+ return 0;
+}
+
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk