libcvd-members
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [libcvd-members] SubImages no longer need to be distinct from BasicI


From: Gerhard Reitmayr
Subject: Re: [libcvd-members] SubImages no longer need to be distinct from BasicImages.
Date: Wed, 29 Oct 2008 15:34:31 +0000
User-agent: Thunderbird 2.0.0.16 (X11/20080720)

results for grimlock:

grimlock gr281: ./speed-4.3

forloop 5.66416  (494985830000)
imageref 16.0313  (494985830000)
basicimage_iterator 5.23627  (494985830000)
subimage_iterator 9.21517  (494985830000)
subimage_iterator_fastend 7.31546  (494985830000)
subimage_iterator_stl 9.71502  (494985830000)
basicimage_iterator_stl 5.15991  (494985830000)

grimlock gr281: ./speed

forloop 9.41252  (494985830000)
imageref 16.5565  (494985830000)
basicimage_iterator 7.27119  (494985830000)
subimage_iterator 9.27955  (494985830000)
subimage_iterator_fastend 9.3102  (494985830000)
subimage_iterator_stl 9.82064  (494985830000)
basicimage_iterator_stl 7.03666  (494985830000)

grimlock gr281: g++-4.3 -v
gcc version 4.3.3 20080915 (prerelease) [gcc-4_3-branch revision 140371]

grimlock gr281: g++ -v
gcc version 4.2.3 20071030 (prerelease) (SUSE Linux)

grimlock gr281: cat /proc/cpuinfo
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 15
model name      : Intel(R) Core(TM)2 CPU          6600  @ 2.40GHz
stepping        : 6
cpu MHz         : 2394.000
cache size      : 4096 KB

Gerhard


E. Rosten wrote:
> SubImages were originally distinct from BasicImages for speed, since
> BasicImages used raw pointers for iterators, and SubImage iterators were
> somewhat more complex.
> 
> Here are the timing results for a simple function (summing up all pixels
> in an image):
> 
> 
> forloop 16.3304  (494985830000)
> imageref 20.2895  (494985830000)
> basicimage_iterator 16.7697  (494985830000)
> subimage_iterator 16.4321  (494985830000)
> subimage_iterator_fastend 17.8282  (494985830000)
> subimage_iterator_stl 16.2188  (494985830000)
> basicimage_iterator_stl 16.4601  (494985830000)
> 
> Interesting points:
> 
> ImageRef scanning is no longer 10x slower than other methods
> 
> pointers are slower than more complex iterators.
> 
> The fastend speed hack is now a slowness hack.
> 
> The STL is faster than the hand coded algorithm.
> 
> gcc version 4.3.1 20080507 (prerelease)
> 
> CPU is:
> 
> cpu family      : 15
> model           : 3
> model name      : Intel(R) Pentium(R) 4 CPU 3.20GHz
> stepping        : 4
> cpu MHz         : 3207.370
> cache size      : 1024 KB
> 
> 
> Anyone else want to check these results?
> 
> 
> Here's the code:
> 
> #include <cvd/image.h>
> #include <cvd/timer.h>
> #include <iostream>
> #include <functional>
> #include <numeric>
> #include <cstdlib>
> using namespace CVD;
> using namespace std;
> 
> int basicimage_iterator_stl(const BasicImage<int>& im)
> {
>     return accumulate(im.begin(), im.end(), 0, plus<int>());
> }
> 
> int subimage_iterator_stl(const SubImage<int>& im)
> {
>     return accumulate(im.begin(), im.end(), 0, plus<int>());
> }
> 
> int basicimage_iterator(const BasicImage<int>& im)
> {
>     int sum=0;
>     for(BasicImage<int>::const_iterator i = im.begin(); i != im.end(); i++)
>         sum += *i;
> 
>     return sum;
> }
> 
> int subimage_iterator_fastend(const SubImage<int>& im)
> {
>     int sum=0;
>     for(SubImage<int>::const_iterator i = im.begin(); i != im.fastend();
> i++)
>         sum += *i;
> 
>     return sum;
> }
> 
> int subimage_iterator(const SubImage<int>& im)
> {
>     int sum=0;
>     for(SubImage<int>::const_iterator i = im.begin(); i != im.end(); i++)
>         sum += *i;
> 
>     return sum;
> }
> 
> 
> int forloop(const SubImage<int>& im)
> {
>     int sum=0;
>     for(int y=0; y < im.size().y; y++)
>         for(int x=0; x < im.size().x; x++)
>             sum += im[y][x];
> 
>     return sum;
> }
> 
> 
> int imageref(const SubImage<int>& im)
> {
>     int sum=0;
>     ImageRef scan(0,0);
> 
>     do
>     {
>         sum += im[scan];
>     }while(scan.next(im.size()));
> 
>     return sum;
> }
> 
> #define TEST(X)\
> {\
>   long long sum=0;\
>   cvd_timer t;\
>   for(int i=0; i < 10000; i++)\
>       sum += X(im);\
>   cout << #X << " " << t.get_time() << "  (" << sum << ")\n";\
> }
> 
> 
> int main()
> {
>     Image<int> im(ImageRef(1000,1000));
> 
>     for(Image<int>::iterator i=im.begin(); i != im.end(); i++)
>         *i = rand() % 100;
> 
>     TEST(forloop);
>     TEST(imageref);
>     TEST(basicimage_iterator);
>     TEST(subimage_iterator);
>     TEST(subimage_iterator_fastend);
>     TEST(subimage_iterator_stl);
>     TEST(basicimage_iterator_stl);
> }
> 
> 
> 


-- 
Gerhard Reitmayr
MIL, Engineering Department, Cambridge University
http://www.eng.cam.ac.uk/~gr281/
tel: +44 1223 765150




reply via email to

[Prev in Thread] Current Thread [Next in Thread]