1[/============================================================================== 2 Copyright (C) 2001-2011 Joel de Guzman 3 Copyright (C) 2001-2011 Hartmut Kaiser 4 5 Distributed under the Boost Software License, Version 1.0. (See accompanying 6 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 7===============================================================================/] 8 9[section:numeric_performance Performance of Numeric Generators] 10 11[section:int_performance Comparing the performance of a single int_ generator] 12 13These performance measurements are centered around default formatting of a 14single `int` integer number using different libraries and methods. 15The overall execution times for those examples are compared below. We compare 16using `sprintf`, C++ iostreams, __boost_format__, and __karma__. 17 18For the full source code of the performance test please see here: 19[@../../workbench/karma/int_generator.cpp int_generator.cpp]. All the 20measurements have been done by executing `1e7` iterations for each 21formatting type (NUMITERATIONS is set to `1e7` in the code shown below). 22 23[import ../../workbench/karma/int_generator.cpp] 24 25Code used to measure the performance for `ltoa`: 26 27[karma_int_performance_ltoa] 28 29Code used to measure the performance for standard C++ iostreams: 30 31[karma_int_performance_iostreams] 32 33Code used to measure the performance for __boost_format__: 34 35[karma_int_performance_format] 36 37Code used to measure the performance for __karma__ using a plain character buffer: 38 39[karma_int_performance_plain] 40 41The following table shows the overall performance results collected 42while using different compilers. All times are in seconds measured for `1e7` 43iterations (platform: Windows7, Intel Core Duo(tm) Processor, 2.8GHz, 4GByte RAM). 44For a more readable comparison of the results see this 45[link spirit.karma.int_performance figure]. 46 47[table Performance comparison for a single int (all times in [s], `1e7` iterations) 48 [[Library] [gcc 4.4.0 (32 bit)] [VC++ 10 (32 bit)] [Intel 11.1 (32 bit)] [gcc 4.4.0 (64 bit)] [VC++ 10 (64 bit)] [Intel 11.1 (64 bit)]] 49 [[ltoa] [1.542] [0.895] [0.884] [1.163] [1.099] [0.906]] 50 [[iostreams] [6.548] [13.727] [11.898] [3.464] [8.316] [8.115]] 51 [[__boost_format__] [16.998] [21.813] [20.477] [17.464] [14.662] [13.646]] 52 [[__karma__ int_] [1.421] [0.744] [0.697] [1.072] [0.953] [0.606]] 53] 54 55[fig int_performance.png..Performance comparison for a single int..spirit.karma.int_performance] 56 57[endsect] 58 59[/////////////////////////////////////////////////////////////////////////////] 60[section:double_performance Comparing the performance of a single double_ generator] 61 62These performance measurements are centered around default formatting of a 63single `double` floating point number using different libraries and methods. 64The overall execution times for those examples are compared below. We compare 65using `sprintf`, C++ iostreams, __boost_format__, and __karma__. 66 67For the full source code of the performance test please see here: 68[@../../workbench/karma/double_performance.cpp double_performance.cpp]. All the 69measurements have been done by executing `1e6` iterations for each 70formatting type (NUMITERATIONS is set to `1e6` in the code shown below). 71 72[import ../../workbench/karma/double_performance.cpp] 73 74Code used to measure the performance for `sprintf`: 75 76[karma_double_performance_printf] 77 78Code used to measure the performance for standard C++ iostreams: 79 80[karma_double_performance_iostreams] 81 82Code used to measure the performance for __boost_format__: 83 84[karma_double_performance_format] 85 86The following code shows the common definitions used by all __karma__ performance 87measurements as listed below: 88 89[karma_double_performance_definitions] 90 91Code used to measure the performance for __karma__ using a plain character buffer: 92 93[karma_double_performance_plain] 94 95The following table shows the overall performance results collected 96while using different compilers. All times are in seconds measured for `1e6` 97iterations (platform: Windows7, Intel Core Duo(tm) Processor, 2.8GHz, 4GByte RAM). 98For a more readable comparison of the results see this 99[link spirit.karma.double_performance figure]. 100 101[table Performance comparison for a single double (all times in [s], `1e6` iterations) 102 [[Library] [gcc 4.4.0 (32 bit)] [VC++ 10 (32 bit)] [Intel 11.1 (32 bit)] [gcc 4.4.0 (64 bit)] [VC++ 10 (64 bit)] [Intel 11.1 (64 bit)]] 103 [[sprintf] [0.755] [0.965] [0.880] [0.713] [0.807] [0.694]] 104 [[iostreams] [2.316] [2.624] [1.964] [1.634] [1.468] [1.354]] 105 [[__boost_format__] [3.188] [3.737] [2.878] [3.217] [2.672] [2.011]] 106 [[__karma__ double_] [0.813] [0.561] [0.368] [0.426] [0.260] [0.218]] 107] 108 109[fig double_performance.png..Performance comparison for a single double..spirit.karma.double_performance] 110 111[endsect] 112 113[////////////////////////////////////////////////////////////////////////////] 114[section:format_performance Comparing the performance of a sequence of several generators] 115 116These performance measurements are centered around formatting of a sequence of 117different items, including 2 `double` floating point numbers using different 118libraries and methods. The overall execution times for those examples are 119compared below. We compare using `sprintf`, C++ iostreams, __boost_format__, 120and __karma__. 121 122For the full source code of the performance test please see here: 123[@../../workbench/karma/format_performance.cpp format_performance.cpp]. All the 124measurements have been done by doing `1e6` iterations for each formatting 125type (NUMITERATIONS is set to `1e6`). 126 127[import ../../workbench/karma/format_performance.cpp] 128 129Code used to measure the performance for sprintf: 130 131[karma_format_performance_printf] 132 133Code used to measure the performance for standard iostreams: 134 135[karma_format_performance_iostreams] 136 137Code used to measure the performance for __boost_format__: 138 139[karma_format_performance_format] 140 141The following code shows the common definitions used by all __karma__ 142performance measurements as listed below: 143 144[karma_format_performance_definitions] 145 146Code used to measure the performance for __karma__ using a plain character 147buffer: 148 149[karma_format_performance_plain] 150 151The following table shows the overall performance results collected 152while using different compilers. All times are in seconds measured for `1e6` 153iterations (platform: Windows7, Intel Core Duo(tm) Processor, 2.8GHz, 4GByte RAM). 154For a more readable comparison of the results see this 155[link spirit.karma.format_performance figure]. 156 157[table Performance comparison for a sequence of several items (all times in [s], `1e6` iterations) 158 [[Library] [gcc 4.4.0 (32 bit)] [VC++ 10 (32 bit)] [Intel 11.1 (32 bit)] [gcc 4.4.0 (64 bit)] [VC++ 10 (64 bit)] [Intel 11.1 (64 bit)]] 159 [[sprintf] [1.725] [1.892] [1.903] [1.469] [1.608] [1.493]] 160 [[iostreams] [4.827] [5.287] [4.444] [3.112] [3.319] [2.877]] 161 [[__boost_format__] [5.881] [7.089] [5.801] [5.455] [5.254] [4.164]] 162 [[__karma__] [1.942] [1.242] [0.999] [1.334] [0.758] [0.686]] 163] 164 165[fig format_performance.png..Performance comparison for a sequence of several items..spirit.karma.format_performance] 166 167[endsect] 168 169[endsect] 170