Was curious as to the speed of floating point operations on the 16MHz Arduino Diecimila. Could only find a few threads about that (e.g., http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1206534749), with no answer, so I ran some tests. Here's a graph of results comparing the speed of a multiply operation using the various data types:

(http://i187.photobucket.com/albums/x269/jmknapp/speedtest.png)

The way the C test program was set up, the values above include the time for the multiply operation as well as one memory read and one memory write.

These are the lengths of the data types in bytes:

byte 1int 2long int 4double 4

I also looked at the time to do a sin() call to the math library: 255 microseconds!

Anyway, based on these results, looks like the Diecimila is about a 0.1 megaflop device, using 4-byte floats/doubles.

Was curious as to the speed of floating point operations on the 16MHz Arduino Diecimila. Could only find a few threads about that (e.g., http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1206534749), with no answer, so I ran some tests.

As the person who started the other thread thank you for that.

I must say I'm surprised it can do doubles so fast. Do you have data for division? With division algorithms, you'll need to test a wide range of denominators to get a good feel.

I just tried it with several different denominators & always get a result in the range of 34 microseconds. So floating point division is about 3-4 times slower than multiplication (9 usec).

Even so, that's about 30,000 divisions per second. This seems fast enough for (much) government work! ::)

Hey, I work for the government ;)

34 microseconds is amazing. I originally tried to do my current project on a pic16F, and was getting results about a thousand times slower. It was at the point where I was trying to use 2 PICs, one basically as a floating-point processor, and the whole project got kludgy. Not to mention all the fun I had learning how to do floating point division in assembly on a processor that only does 8-bit integer add and subtract.

Because of the speed, it just works on the Ardunio. And the HLL is so much faster than messing around with assembly or JAL. What took me weeks on the PIC took an hour on the Arduino.

Quote

I would tend to believe what the compiler is reporting, but I just posted something on this in Bugs/Suggestions, so we will see.

I saw your post there, I'm looking forward to seeing the answer. If we trust the compiler, there's no difference beween float and double though. Float is good enough for my purposes though.

Confirmed, in winavr float == double (source: "WinAVR / gccavr does not support doubles, in other words: double is considered as float" in http://www.avrfreaks.net/wiki/index.php/Documentation:AVR_Float) and also from the maintainer of avr-libc: http://www.avrfreaks.net/index.php?module=PNphpBB2&file=viewtopic&t=50770&highlight=