From subsecret
Jump to: navigation, search
No edit summary
No edit summary
Line 28: Line 28:
|}
|}


Benchmark of analog sensor read  
Benchmark of analog sensor read (100000 analogRead())
 
{| class="wikitable"
!Model
!Duration
|-
|Arduino 101
| 280 ms.
|-
|Arduino Mega 2560 (clone)
|  ms.
|}


Benchmark of pi calculation
Benchmark of pi calculation

Revision as of 19:01, 30 April 2017

Benchmark of internal time precision

Model range of 60 sec delay() call avg. duration of 60 sec delay() call
Arduino 101 59998-59999 59998,5625
Arduino Mega 2560 (clone) 59989-59994 59991,75


Benchmark of digital sensor read (100000 digitalRead())

Model Duration
Arduino 101 156 ms.
Arduino Mega 2560 (clone) 534 ms.

Benchmark of analog sensor read (100000 analogRead())

Model Duration
Arduino 101 280 ms.
Arduino Mega 2560 (clone) ms.

Benchmark of pi calculation

Model size of double duration (internal time used for measurement) pi value
Arduino 101 8 3879 ms. 3.1415936536
Arduino Mega 2560 (clone) 4 58338 ms. 3.1415972709



Test programs: Python program for measuring response time

import time
import serial
def millis():
    return int(round(time.time() * 1000))
ser = serial.Serial('/dev/ttyACM0', 9600)
while True:
	start = millis()
	data= "recv: "+ser.readline()	
	end = millis()
	print (end-start)
	print data


Time precision benchmark

void setup() {
  Serial.begin(9600);
}

void loop() { 

  while (true) {
    unsigned long start = millis();
    delay(60000);
    unsigned elap = millis() - start;
    Serial.println(elap);
  }
}

Pi benchmark (adapted from http://forum.arduino.cc/index.php?topic=138802.0)

#define ITERATIONS 1000000L    // number of iterations

void setup() {
  Serial.begin(9600);
}

void loop() {

  unsigned long start, time;
  unsigned long niter = ITERATIONS;

  double x = 1.0;
  double pi = 1.0;
  unsigned long i = 0;
  start = millis();
  Serial.print("Sizeof(double)=");
  Serial.print(sizeof(double));
  Serial.println();

  for ( i = 2; i < niter; i++) {
    x *= -1.0;
    pi += x / (2.0 * (double)i - 1);
  }

  time = millis() - start;

  pi = pi * 4.0;

  Serial.print("# of trials = ");
  Serial.println(niter);
  Serial.print("Estimate of pi = ");
  Serial.println(pi, 10);

  Serial.print("Time: ");
  Serial.print(time);
  Serial.println(" ms");
  Serial.println();
  delay(5000);
}