Create a gist now

Instantly share code, notes, and snippets.

anonymous /add_test_4
Created May 2, 2015

Simple Benchmark for Arduino 16-bit addition
long millis_old = 0;
long millis_now =0;
int x=1;
int y=2;
int z=3;
int angle;
long sum = 0;
int m[750]; // a 1500 byte array
void setup()
{
Serial.begin(115200);
for(int i = 0; i <=750; i++)
{
m[i] = random(0,65535);
}
for(int i = 0; i <=31; i++)
{
Serial.println(m[i]);
}
delay(5000);
}
void loop()
{
millis_old = micros();
//Serial.println(millis_old);
{
for (int i = 1; i <=500; i++)
{
// x = sin(i) * 100;
// y = /os(i) * 100;
// z = tan(i) * 100;
m[500-i] = (m[i] + m[500-i]); // add two memory locations
// Serial.println(sum);
}
millis_now = micros();
Serial.println(millis_now - millis_old);
Serial.print("sum =");
Serial.println(sum);
sum = 0;
}
delay(1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment