32 using std::ostringstream;
51 TimeStamp time_converters[10], time_sprintf[10], time_iostreams[10];
55 unsigned int ui = 123;
58 double d = -2316.1234;
63 ostringstream ostream;
65 for (
int j = 0; j < 50; ++j ) {
66 sprintf(buffer,
"%d",i);
67 sprintf(buffer,
"%f",
f);
76 sprintf(buffer,
"%d",i);
77 time_sprintf[0] = stopwatch.split();
78 sprintf(buffer,
"%d",ui);
79 time_sprintf[1] = stopwatch.split();
80 sprintf(buffer,
"%ld",l);
81 time_sprintf[2] = stopwatch.split();
82 sprintf(buffer,
"%f",
f);
83 time_sprintf[3] = stopwatch.split();
84 sprintf(buffer,
"%lf",
d);
85 time_sprintf[4] = stopwatch.split();
92 time_iostreams[0] = stopwatch.split();
94 time_iostreams[1] = stopwatch.split();
96 time_iostreams[2] = stopwatch.split();
98 time_iostreams[3] = stopwatch.split();
100 time_iostreams[4] = stopwatch.split();
123 char_string = toCharString(
f);
124 char_string = toCharString(
f);
125 char_string = toCharString(
f);
126 char_string = toCharString(
f);
128 char_string = toCharString(i);
129 time_converters[0] = stopwatch.split();
130 char_string = toCharString(ui);
131 time_converters[1] = stopwatch.split();
132 char_string = toCharString(l);
133 time_converters[2] = stopwatch.split();
134 char_string = toCharString(
f);
135 time_converters[3] = stopwatch.split();
136 char_string = toCharString(
d);
137 time_converters[4] = stopwatch.split();
140 std::cout << std::endl;
141 std::cout <<
"***********************************************************" << std::endl;
142 std::cout <<
" Performance comparison of char string conversion apis" << std::endl;
143 std::cout <<
"***********************************************************" << std::endl;
144 std::cout << std::endl;
146 std::cout <<
"Converter<char*>(int) " <<
" Time: " << time_converters[0] << std::endl;
147 std::cout <<
"Converter<char*>(unsigned int) " <<
" Time: " << time_converters[1] << std::endl;
148 std::cout <<
"Converter<char*>(long) " <<
" Time: " << time_converters[2] << std::endl;
149 std::cout <<
"Converter<char*>(float) " <<
" Time: " << time_converters[3] << std::endl;
150 std::cout <<
"Converter<char*>(double) " <<
" Time: " << time_converters[4] << std::endl;
151 std::cout << std::endl;
152 std::cout <<
"sprintf(int) " <<
" Time: " << time_sprintf[0] << std::endl;
153 std::cout <<
"sprintf(unsigned int) " <<
" Time: " << time_sprintf[1] << std::endl;
154 std::cout <<
"sprintf(long) " <<
" Time: " << time_sprintf[2] << std::endl;
155 std::cout <<
"sprintf(float) " <<
" Time: " << time_sprintf[3] << std::endl;
156 std::cout <<
"sprintf(double) " <<
" Time: " << time_sprintf[4] << std::endl;
157 std::cout << std::endl;
158 std::cout <<
"ostringstream(int) " <<
" Time: " << time_iostreams[0] << std::endl;
159 std::cout <<
"ostringstream(unsigned int) " <<
" Time: " << time_iostreams[1] << std::endl;
160 std::cout <<
"ostringstream(long) " <<
" Time: " << time_iostreams[2] << std::endl;
161 std::cout <<
"ostringstream(float) " <<
" Time: " << time_iostreams[3] << std::endl;
162 std::cout <<
"ostringstream(double) " <<
" Time: " << time_iostreams[4] << std::endl;
163 std::cout << std::endl;