[SDL] single pixel drawing

Bob Pendleton bob at pendleton.com
Thu Jul 18 15:41:01 PDT 2002

Atrix Wolfe wrote:
> how bout at run time you factor the pitch into powers of 2 and then 
> create your full pixel drawing function (if there are 100 dots drawn put 
> the for loop in and such) and "compile" it to the native machine code.  
> Hows that for efficiency?

That pretty good, we used to do things like that back in the days of 10 
megahertz 286s because we needed to. In these days where a stinking slow 
computer runs at 100 megahertz and a reasonable new computer runs at 800 
  to 2200 megahertz, it seems like a waste of life span to even worry 
about this for an application that is writing 100 pixels. Lets see, if 
we can do (s*y)+x using 1 shift and 1 add I can do it in 2 cycles and I 
spend 200 cycles on arithmetic and if I need 2 shifts and and 2 adds I 
spend 400 cycles, and if it take more shifts and adds than that then I 
should use a multiply becasue a mulitply and and add are 5 cycles (all 
this cycle information is from previous posts and seems to be based on 
the original Pentium which you can buy at thrift stores for a couple of 
bucks...) Anyway, the difference is at most 300 cycles per frame.

So, at 1000 megahertz 300 cycles is 0.0000003 seconds. That's how much 
you might save wow, remind me to waste hours arguing about how to save 
0.0000003 seconds again. Life is too short to be worrying about 
0.0000003 seconds. Get some perspective people.

		Bob Pendleton

+ Bob Pendleton, an experienced C/C++/Java +
+ UNIX/Linux programmer, researcher, and   +
+ system architect, is seeking full time,  +
+ consulting, or contract employment.      +
+ Resume: http://www.jump.net/~bobp        +
+ Email:  bob at pendleton.com                +

More information about the SDL mailing list