[Ffmpeg-devel] int vs. float: Hard Numbers

Mike Melanson mike
Fri May 20 20:13:24 CEST 2005


Hi,
	Persuant to the discussion about whether int or float ops were more 
efficient on today's production CPUs, I performed some empirical tests.

	Tests written using gcc+nasm and clocked using the Intel timestamp 
counter register (TSC) found in Pentium+ CPUs. I compared additions and 
multiplications. Results:

integer_adder() (10 adds) returned 50, 36 cycles used
float_adder() (10 adds) returned 50.000000, 36 cycles used
integer_mult() (10 mults) returned 9765625, 115 cycles used
float_mult() (10 mults) returned 9765625.000000, 36 cycles used

Interesting notes:
* the "float" routines are all actually 64-bit double math; I just 
didn't name them correctly
* the read TSC instruction + other overhead between the rdtsc markers 
was 26 cycles; thus, for 3/4 tests, each instruction actually required 1 
clock cycle
* the cycle count for integer_adder() floated around (36 was the lower 
limit) but the cycle counts for the others are highly consistent
* the integer_mult() function had a few more instructions between the 
markers (2 extra movs), but I do not think that entirely accounts for 
the discrepancy

	If anyone wants the code for these tests, let me know.

	Felker: I await your typical analysis based on these results ("OMG!!1! 
Intel sUx!!"). These tests were not conducted specifically on an 
Intel-branded chip, though it is a P3-class chip.

-- 
	-Mike Melanson





More information about the ffmpeg-devel mailing list