Boost logo

Boost :

Subject: Re: [boost] [uuids] On boost::uuids::uuid operator == performance.
From: Michael Kochetkov (michael.kv_at_[hidden])
Date: 2012-04-16 15:05:49


> BTW if you are interested in the final result you do need to initialize
your
> uuids with some random values. VC initializes all bytes with zeros and is
smart
> enough to remember that id1 does not change:
Ok. I just cannot help it. I have corrected the ids declarations myself the
following way
int main()
{
    boost::uuids::uuid id1((boost::uuids::random_generator()())),
id2((boost::uuids::random_generator()()));
  ...

and my results are as following:
Eq16 -- 100%
my_memcmp -- 138.89 %
memcmp -- 169.17 %
operator == -- 199.72 %

Eq16 became even faster. This is most likely due to the fact the first
comparison became to fire much more often.

Anyway with proper alignment (and I am dead sure every compiler that is
sensitive to the alignment has a proper tweakster for it) Eq16 (it shall
read Eq32 indeed) shall be the fastest way to compare uint8_t[16] array.
Unless you are going to implement Eq64 for x64 platforms...

BTW, for unoptimized (Debug) mode:
Eq16 (optimized) -- 100 %
operator == (optimized) -- 199.72 %
Eq16 (unoptimized) -- 247.5 %
operator == (unoptimized) -- 1419.16 %

No comments.

--
Michael Kochetkov

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