|
Boost : |
From: Andy (atompkins_at_[hidden])
Date: 2007-05-30 10:01:29
"Christian Henning" <chhenning_at_[hidden]> wrote in
news:949801310705291442q6067e19dsb0bd26722561b71f_at_[hidden]:
> I like the way you circumvent the license problem. Rewriting. Cool
Thanks :)
>
> One question. One person reported that the uuid lib was quite slow in
> comparison to C# for instance. Could you resolve that, too?
I did optimize the random-based create function. It, of course, does
depend on the random number generator used.
The uuid::create(engine) (using mt19937) is now a little faster then
.NET's. For 10,000,000 calls to uuid::create(engine), I get 3.937s, and
for .NET's Guid::NewGuid(), I get 4.375s.
The name-based uuid::create function has not been optimized.
Here are the tests I used:
#include "stdafx.h"
#using <mscorlib.dll>
using namespace System;
int _tmain()
{
const int N = 10000000;
DateTime t0 = DateTime::Now;
for (int i = 0; i < N; i++) {
Guid::NewGuid();
}
TimeSpan ts = DateTime::Now - t0;
Console::WriteLine(ts.ToString());
return 0;
}
and:
#include <boost\progress.hpp>
#include <boost\uuid.hpp>
#include <iostream>
#include <boost/random.hpp>
int main(int argc, char* argv[])
{
using namespace boost;
const int N = 10000000;
mt19937 engine;
timer t1;
for (int i=0; i<N; ++i) {
uuid::create(engine);
}
std::cout << t1.elapsed() << '\n';
return 0;
}
>
> Thanks for your great work,
> Christian
< snip >
Andy.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk