Re: Convert color-image to bw *fast*
- From: "Michael C" <nospam@xxxxxxxxxx>
- Date: Fri, 3 Nov 2006 13:48:17 +1100
"Joergen Bech @ post1.tele.dk>" <jbech<NOSPAMNOSPAM> wrote in message
news:k20kk29s1cf4cenllgjnlbvo0rjr5easid@xxxxxxxxxx
The result are then
Float: 661
Double: 569
Integer: 370
I found a few problems in your test. The first I found when I ran your test
and got no results, took me a while to figure out you were using
Debug.WriteLine instead of Console.WriteLine so nothing was coming out in
release mode. The tests should probably be run in release. The second
problem I found was that all the code we were actually testing got optimised
out in release, the results were all around 200ms with random variations of
up to 40ms. The other problem I found was red, green and blue were constant
values of zero so probably also optimised out. If they were not optimised
out then they *might* favour the doubles. Red, green and blue were ints but
in the original problem they were bytes. I changed the code so the
double/float/int value goes into a variable, just to make sure we are
actually dealing with the correct datatype and the compiler isn't doing some
optimisations.
Although with all the changes I got even closer results than you and am not
sure my tests are any more valid :-) I think that would be due to the extra
code I've added inside the loop to ensure everything gets executed and the
rgb values get incremented.
Double: 7266
Float: 9406
Int: 6578
The results basically agree with your assesment on floats and doubles are
suprisingly close to ints. I find these results quite odd though, double is
64 bit and int is of course 32. Surely just that would be enough to make it
slower (although I guess this is reflected in your results of 569 vs 370).
In the actual real life test comparing the processing of my large bitmap
between ints and doubles (both inline and the /255 removed) I got 78ms vs
125ms. Not a lot of difference but still 50% faster. For a high level
language c# does pretty well, I calculated that it was executing each
iteration of your loops in 12 instructions. :-)
Michael
.
- Follow-Ups:
- Re: Convert color-image to bw *fast*
- From: Joergen Bech
- Re: Convert color-image to bw *fast*
- References:
- Re: Convert color-image to bw *fast*
- From: henning.friese@xxxxxx
- Re: Convert color-image to bw *fast*
- From: Joergen Bech
- Re: Convert color-image to bw *fast*
- From: Bob Powell [MVP]
- Re: Convert color-image to bw *fast*
- From: Joergen Bech
- Re: Convert color-image to bw *fast*
- From: Michael C
- Re: Convert color-image to bw *fast*
- From: Joergen Bech
- Re: Convert color-image to bw *fast*
- From: Michael C
- Re: Convert color-image to bw *fast*
- From: Joergen Bech
- Re: Convert color-image to bw *fast*
- From: Michael C
- Re: Convert color-image to bw *fast*
- From: Joergen Bech
- Re: Convert color-image to bw *fast*
- From: Joergen Bech
- Re: Convert color-image to bw *fast*
- Prev by Date: Re: Identify shape in image
- Next by Date: Re: Convert color-image to bw *fast*
- Previous by thread: Re: Convert color-image to bw *fast*
- Next by thread: Re: Convert color-image to bw *fast*
- Index(es):
Relevant Pages
|