Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r55025 - in trunk/libs/spirit: benchmarks/karma doc
From: hartmut.kaiser_at_[hidden]
Date: 2009-07-18 23:42:35


Author: hkaiser
Date: 2009-07-18 23:42:34 EDT (Sat, 18 Jul 2009)
New Revision: 55025
URL: http://svn.boost.org/trac/boost/changeset/55025

Log:
Spirit: added one more Karma benchmark
Added:
   trunk/libs/spirit/benchmarks/karma/sequence_performance.cpp (contents, props changed)
Binary files modified:
   trunk/libs/spirit/doc/karma_performance.xlsx
Text files modified:
   trunk/libs/spirit/benchmarks/karma/CMakeLists.txt | 3 ++-
   trunk/libs/spirit/benchmarks/karma/Jamfile | 3 ++-
   2 files changed, 4 insertions(+), 2 deletions(-)

Modified: trunk/libs/spirit/benchmarks/karma/CMakeLists.txt
==============================================================================
--- trunk/libs/spirit/benchmarks/karma/CMakeLists.txt (original)
+++ trunk/libs/spirit/benchmarks/karma/CMakeLists.txt 2009-07-18 23:42:34 EDT (Sat, 18 Jul 2009)
@@ -10,6 +10,7 @@
 boost_add_executable(int_generator)
 boost_add_executable(real_generator)
 boost_add_executable(format_performance)
-boost_add_executable(format_performance)
+boost_add_executable(double_performance)
+boost_add_executable(sequence_performance)
 
 

Modified: trunk/libs/spirit/benchmarks/karma/Jamfile
==============================================================================
--- trunk/libs/spirit/benchmarks/karma/Jamfile (original)
+++ trunk/libs/spirit/benchmarks/karma/Jamfile 2009-07-18 23:42:34 EDT (Sat, 18 Jul 2009)
@@ -10,5 +10,6 @@
 # performance tests
 exe int_generator : int_generator.cpp ;
 exe real_generator : real_generator.cpp ;
+exe format_performance : format_performance.cpp ;
 exe double_performance : double_performance.cpp ;
-exe double_performance : double_performance.cpp ;
+exe sequence_performance : sequence_performance.cpp ;

Added: trunk/libs/spirit/benchmarks/karma/sequence_performance.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/spirit/benchmarks/karma/sequence_performance.cpp 2009-07-18 23:42:34 EDT (Sat, 18 Jul 2009)
@@ -0,0 +1,52 @@
+// Copyright (c) 2005-2009 Hartmut Kaiser
+//
+// 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)
+
+#define FUSION_MAX_TUPLE_SIZE 10
+
+#include <climits>
+
+#include <iostream>
+#include <boost/preprocessor/repeat.hpp>
+#include <boost/preprocessor/inc.hpp>
+
+#include <boost/spirit/include/karma.hpp>
+
+#include "../high_resolution_timer.hpp"
+
+///////////////////////////////////////////////////////////////////////////////
+#define MAX_ITERATION 10000000
+#define MAX_SEQUENCE_LENGTH 9
+#define RCHAR(z, n, _) char_((char)std::rand()) <<
+
+#define SEQUENCE_TEST(z, N, _) \
+ { \
+ util::high_resolution_timer t; \
+ \
+ std::srand(42); \
+ for (int i = 0; i < MAX_ITERATION; ++i) \
+ { \
+ char *ptr = buffer; \
+ generate(ptr, BOOST_PP_REPEAT(N, RCHAR, _) char_('\0')); \
+ } \
+ \
+ std::cout << "karma::sequence(" << BOOST_PP_INC(N) << "):\t" \
+ << t.elapsed() << " [s]" \
+ << std::flush << std::endl; \
+ } \
+ /**/
+
+///////////////////////////////////////////////////////////////////////////////
+int
+main()
+{
+ using namespace boost::spirit::karma;
+ using namespace boost::spirit::ascii;
+ char buffer[512]; // we don't expect more than 512 bytes to be generated here
+
+ std::cout << "Benchmarking sequence of different length: " << std::endl;
+ BOOST_PP_REPEAT_FROM_TO(1, MAX_SEQUENCE_LENGTH, SEQUENCE_TEST, _);
+
+ return 0;
+}

Modified: trunk/libs/spirit/doc/karma_performance.xlsx
==============================================================================
Binary files. No diff available.


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