]> git.piffa.net Git - arduino/blob - books/ArduinoNextSteps-master/ArduinoNextSteps/sketch_04_02_benchmark_float/sketch_04_02_benchmark_float.ino
first commit
[arduino] / books / ArduinoNextSteps-master / ArduinoNextSteps / sketch_04_02_benchmark_float / sketch_04_02_benchmark_float.ino
1 // sketch 04_02_benchmark_float
2
3 void setup()
4 {
5   Serial.begin(9600);
6   while (! Serial) {};
7   Serial.println("Starting Test");
8   long startTime = millis();
9   
10   // test code here
11   long  i = 0;
12   float j = 0.0;
13   for (i = 0; i < 20000000; i ++)
14   {
15     j = i + i * 10.0;
16     if (j > 10) j = 0.0;
17   }
18   // end of test code
19   long endTime = millis();
20   
21   Serial.println(j); // prevent loop being optimized out
22   Serial.println("Finished Test");
23   Serial.print("Seconds taken: "); 
24   Serial.println((endTime - startTime) / 1000l);
25 }
26
27 void loop()
28 {
29   
30 }