Boost logo

Boost :

Subject: Re: [boost] [convert] Performance
From: Matus Chochlik (chochlik_at_[hidden])
Date: 2014-06-10 04:04:32


On Tue, Jun 10, 2014 at 8:58 AM, Vladimir Batov <vb.mail.247_at_[hidden]>
wrote:

> > IMHO this could have something to do with paging or the caching of the
> > strings.
> > You should test the two cases by two separate programs and try to run
> them
> > both in the raw then cnv and cnv then raw orders.
> > Or you could at least try to run
> >
> > for (int k = 0; k < 3; ++k)
> > printf("str-to-int spirit: raw1/raw2=%.2f/%.2f seconds.\n",
> > performance_string_to_int_spirit(strings),
> > performance_string_to_int_spirit(strings));
> >
> > to try it out.
>
> Matus,
>
> Geez, I would never figure that out by myself. Thanks. So, the first call
> would pull the strings into the fast cache so that the second call would
> not
> have to, right? Now I changed the test as
>
> int const num_tries = 20;
> double raw_time = 0;
> double cnv_time = 0;
>

Vladimir,

if this is indeed caused by caching and you want to run both tests in a
single program, then you should do a "dry run" that will cause the strings
to be cached before you do the actual timing.
Also I'd increase the number of tries at least to 200.

>
> for (int k = 0; k < num_tries; ++k)
> raw_time += performance_string_to_int_spirit(strings);
>
> for (int k = 0; k < num_tries; ++k)
> cnv_time += performance::str_to_int(strings, boost::cnv::spirit());
>
> printf("str-to-int spirit: raw/cnv=%.2f/%.2f seconds.\n",
> raw_time / num_tries,
> cnv_time / num_tries);
>
> Does it look fair to you? It surely gives more realistic results with
> bosst::convert() adding 0.7% overhead:
>
> 32:~/dev/boost.convert.>> ~/dev/bin/test-convert
> str-to-int spirit: raw/cnv=1.41/1.42 seconds.
>
>


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk