11903976dSEric Fiselier #include "benchmark/benchmark.h"
2*fca28db9SEric Fiselier #include "test_macros.h"
338bc3df8SAditya Kumar 
438bc3df8SAditya Kumar #include <sstream>
5*fca28db9SEric Fiselier 
6*fca28db9SEric Fiselier TEST_NOINLINE double istream_numbers();
738bc3df8SAditya Kumar 
istream_numbers()838bc3df8SAditya Kumar double istream_numbers() {
938bc3df8SAditya Kumar   const char *a[] = {
1038bc3df8SAditya Kumar     "-6  69 -71  2.4882e-02 -100 101 -2.00005 5000000 -50000000",
1138bc3df8SAditya Kumar     "-25 71   7 -9.3262e+01 -100 101 -2.00005 5000000 -50000000",
1238bc3df8SAditya Kumar     "-14 53  46 -6.7026e-02 -100 101 -2.00005 5000000 -50000000"
1338bc3df8SAditya Kumar   };
1438bc3df8SAditya Kumar 
1538bc3df8SAditya Kumar   int a1, a2, a3, a4, a5, a6, a7;
1638bc3df8SAditya Kumar   double f1 = 0.0, f2 = 0.0, q = 0.0;
1738bc3df8SAditya Kumar   for (int i=0; i < 3; i++) {
1838bc3df8SAditya Kumar     std::istringstream s(a[i]);
1938bc3df8SAditya Kumar     s >> a1
2038bc3df8SAditya Kumar       >> a2
2138bc3df8SAditya Kumar       >> a3
2238bc3df8SAditya Kumar       >> f1
2338bc3df8SAditya Kumar       >> a4
2438bc3df8SAditya Kumar       >> a5
2538bc3df8SAditya Kumar       >> f2
2638bc3df8SAditya Kumar       >> a6
2738bc3df8SAditya Kumar       >> a7;
2838bc3df8SAditya Kumar     q += (a1 + a2 + a3 + a4 + a5 + a6 + a7 + f1 + f2)/1000000;
2938bc3df8SAditya Kumar   }
3038bc3df8SAditya Kumar   return q;
3138bc3df8SAditya Kumar }
3238bc3df8SAditya Kumar 
BM_Istream_numbers(benchmark::State & state)3338bc3df8SAditya Kumar static void BM_Istream_numbers(benchmark::State &state) {
3438bc3df8SAditya Kumar   double i = 0;
3538bc3df8SAditya Kumar   while (state.KeepRunning())
3638bc3df8SAditya Kumar     benchmark::DoNotOptimize(i += istream_numbers());
3738bc3df8SAditya Kumar }
3838bc3df8SAditya Kumar 
3938bc3df8SAditya Kumar BENCHMARK(BM_Istream_numbers)->RangeMultiplier(2)->Range(1024, 4096);
401903976dSEric Fiselier BENCHMARK_MAIN();
41