|
Boost : |
From: Andy (atompkins_at_[hidden])
Date: 2007-05-09 16:44:08
"Dave Jenkins" <david_at_[hidden]> wrote in
news:f1t1qp$ra8$1_at_[hidden]:
< snip >
> - What is your evaluation of the implementation?
>
> I am concerned about the performance of this library when generating a
> large number of GUIDs. I wrote two small programs to compare
> performance between MSVC 8.0 native mode using the Boost.GUID library
> and C++.CLR using the Microsoft System.Guid library. The CLR version
> ran much faster. For ten million GUIDs, the times were 5 seconds for
> System.Guid, 16 seconds for Boost.GUID (random number based) and 12
> seconds for Boost.Guid (name-based). The source code for the programs
> is attached. I would have expected the native mode program to run
> faster or about the same. Is there something wrong with my code?
> Could this be caused by the Thread lock? Or maybe the random number
> generator takes more time?
First we aren't comparing the same thing. System::Guid::NewGuid creates
a time-based guid and my library creates either a name-based or a
random-number-based guid. But regardless, my library should be faster.
I am sad that it is 2-3 times slower. It does not seem to be the thread
lock. Running your test with BOOST_DISABLE_THREADS shows little
improvement. I have not profiled my code yet. I assume that the random
number generator is slower than I would like, but I believe that I may
be using it inefficiently. I will do my best to improve the speed.
>
> - What is your evaluation of the documentation?
>
> At the start of the document, I would prefer a text paragraph or two
> describing what a GUID is, what they look like, and what the library
> does with them (input/output/create). Also, a description of the
> name-based and random-number-based alternatives might help up front.
> In the Design Notes section, could you provide a link to a SHA-1
> reference like http://www.itl.nist.gov/fipspubs/fip180-1.htm.
Agreed.
< snip >
> Regards,
> Dave Jenkins
>
> Attachment decoded: untitled-2.txt
> ------=_NextPart_000_003D_01C79241.6DA221A0
> #include <boost/guid.hpp>
> #include <boost/progress.hpp>
> #include <string>
> #include <vector>
>
> int main(int, char*[])
> {
> using namespace boost;
>
> int const N = 10000000;
> std::vector<guid> g;
> g.reserve(N);
> guid dns_namespace_guid("6ba7b810-9dad-11d1-80b4-00c04fd430c8");
> timer t1;
> for (int i=0; i<N; i++)
> g.push_back(guid::create());
> //g.push_back(guid::create(dns_namespace_guid,
> "www.widgets.com", 15));
>
> std::cout << "elapsed time: " << t1.elapsed() << '\n';
> std::cout << "count: " << N << '\n';
> return 0;
> }
>
> Attachment decoded: Test1.cpp
> ------=_NextPart_000_003D_01C79241.6DA221A0
> // TestCLR.cpp : main project file.
> using namespace System;
> using namespace System::Collections::Generic;
>
> int main(array<System::String ^> ^args)
> {
> const int N = 10000000;
> List<Guid> ^g = gcnew List<Guid>();
> g->Capacity = N;
> DateTime t0 = DateTime::Now;
> for (int i = 0; i < N; i++)
> g->Add(Guid::NewGuid());
> TimeSpan ts = DateTime::Now - t0;
> Console::WriteLine("elapsed time=" + ts.ToString() +
> " Count="+g->Count.ToString());
> return 0;
> }
>
> Attachment decoded: TestCLR.cpp
> ------=_NextPart_000_003D_01C79241.6DA221A0
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost Attachment decoded:
> untitled-5.txt ------=_NextPart_000_003D_01C79241.6DA221A0--
Andy.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk