Boost logo

Boost :

Subject: Re: [boost] [xpressive] Performance Tuning?
From: Edward Grace (ej.grace_at_[hidden])
Date: 2009-07-20 05:05:36

>> Hmm. Depending on what the type of 'ticks' from cycle.h is
>> (that's what
>> you're using right) that should just be a large integer type.
>> Perhaps try
>> with the util::high_resolution_timer, which is of type double().
> According to Visual Assist, ticks is of type LARGE_INTEGER, a union
> type with 4 parts and a max size of 64-bits, it has no operator-
> defined, hence you would need to reference an internal part, it looks
> like QuadPart (like chrono_wall().QuadPart) would work, but that does
> not fit into your design. I added this to the proper place in the
> cycle.h file:
> {
> res.QuadPart = l.QuadPart - r.QuadPart;
> return res;
> }
> Now it says:
> 1>R:\Programming_Projects\Spirit_Price\ejg_uint_parser_timing
> \other_includes\ejg/timer.cpp(117)
> : error C2440: '<function-style-cast>' : cannot convert from
> 'LARGE_INTEGER' to 'double'
> 1> No user-defined-conversion operator available that can
> perform this conversion, or the operator cannot be called
> 1> R:\Programming_Projects\Spirit_Price
> \ejg_uint_parser_timing\other_includes\ejg/timer.cpp(109)
> : while compiling class template member function 'void
> ejg::generic_timer<ticks>::calibrate_seconds(void)'
> 1> with
> 1> [
> 1> ticks=ticks
> 1> ]
> 1> .\ejg_uint_parser.cpp(133) : see reference to class template
> instantiation 'ejg::generic_timer<ticks>' being compiled
> 1> with
> 1> [
> 1> ticks=ticks
> 1> ]
> 1>R:\Programming_Projects\Spirit_Price\ejg_uint_parser_timing
> \other_includes\ejg/timer.cpp(239)
> : warning C4267: '=' : conversion from 'size_t' to 'unsigned int',
> possible loss of data
> 1> .\ejg_uint_parser.cpp(154) : see reference to function
> template instantiation 'void
> ejg::generic_timer<ticks>::measure_percentage_speedup<void(__cdecl
> *)(void),void(__cdecl *)(void)>(_OperationA,_OperationB,double
> &,double &,double &)' being compiled
> 1> with
> 1> [
> 1> ticks=ticks,
> 1> _OperationA=void (__cdecl *)(void),
> 1> _OperationB=void (__cdecl *)(void)
> 1> ]
> 1>R:\Programming_Projects\Spirit_Price\ejg_uint_parser_timing
> \other_includes\ejg/timer.cpp(246)
> : warning C4267: '=' : conversion from 'size_t' to 'unsigned int',
> possible loss of data
> So the union has no conversion to double, of course. Trying

Ahah. Perhaps that's why cycle.h has a macro called 'elapsed',
designed to take the difference between two numbers with these types.

Clearly this is going to be tougher than I thought. I originally
avoided making the list of stored time differences a concrete type
such as double, now it looks like I might have to. Otherwise it will
require sticking lots of extra cruft in as template arguments (a
function for taking differences of times for example).

> What do you want me to do with util::high_resolution_timer?

1) You need to make a chronometer function in global scope such as:

util::high_resolution_timer global_timer_object;

double boost_chrono() {

Internal to the timing library it makes two calls to the chronometer
and uses the difference in the times, so it's important that
util::high_resolution_timer never gets reset. Since it's only double
precision this has subtle implications for long timings.

2) In the instantiation of ejg::generic_timer do replace the stuff
that looks like

        ejg::generic_timer<ticks> timer(getticks);


        ejg::generic_timer<double> timer(boost_chrono);

Everything else should then work from there. Let me know how that goes.

>> Otherwise do you think the compiler is getting confused between
>> the name of
>> the template parameter 'ticks' and the type 'ticks'?
> Hmm, do not know, I never duplicate names like that so have not run
> into that...

Let's assume it's ok for now...

> On Sun, Jul 19, 2009 at 9:51 PM, Joel de
> Guzman<joel_at_[hidden]> wrote:
>> Edward, just a compliment (for now): what you are doing is cool!
>> I'm starting to be an eager supporter.
> I have to say that I like the design of your timer library as well,
> looks to be very useful. :)

Thanks. There are (clearly) some wrinkles to iron out - but that's
why we are here.


"No more boom and bust." -- Dr. J. G. Brown, 1997

Boost list run by bdawes at, gregod at, cpdaniel at, john at