I was doing some speed tests to see how fast my computer (Intel iMac Core2 Duo 2GHz) is at reading and writing different types of data (bytes, shorts, ints, floats etc), based on number of instructions or based on amount of memory read. Looks like if you store a Float as an integer and read it from an Integer it is faster than reading it from a float:
is faster than
Reading the float from binary data stored in an int with an Int Ptr took about 200 millisecs, versus 300 for reading from a Float pointer.
Also
is faster than
Writing the float to memory as an integer of binary data took 167 millisecs, versus 173 millisecs to write a Float to a Float pointer.
Okay so the write isn't that much faster, but the read is significantly faster. Also seems in general that dealing with floats and doubles and longs is substantially slower than dealing with Int's, more than just the extra bytes of memory access.
Maybe reading a floating point number (Float/Double) in from memory entails reading the memory, writing it back out as a float, then reading it into a float variable? I know the PPC processor used to have the issue that a float had to be written to memory before it could be read as an integer, and vice versa.
Local MyFloat:Float IntPtr(VarPtr(MyFloat))[0]=IntegerMemoryPtr[offset]
is faster than
Local MyFloat:Float=FloatMemoryPtr[offset]
Reading the float from binary data stored in an int with an Int Ptr took about 200 millisecs, versus 300 for reading from a Float pointer.
Also
IntegerMemoryPtr[offset]=IntPtr(VarPtr(MyFloat))
is faster than
FloatMemoryPtr[offset]=MyFloat
Writing the float to memory as an integer of binary data took 167 millisecs, versus 173 millisecs to write a Float to a Float pointer.
Okay so the write isn't that much faster, but the read is significantly faster. Also seems in general that dealing with floats and doubles and longs is substantially slower than dealing with Int's, more than just the extra bytes of memory access.
Maybe reading a floating point number (Float/Double) in from memory entails reading the memory, writing it back out as a float, then reading it into a float variable? I know the PPC processor used to have the issue that a float had to be written to memory before it could be read as an integer, and vice versa.