Created
June 27, 2019 12:20
-
-
Save benevpi/562a7ac1e6343f3574801b4ac3ca41cf to your computer and use it in GitHub Desktop.
Arduino speed test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int y; | |
float z; | |
int start; | |
String board = "Arduino Nano Every"; | |
int sensorValue; | |
long loops = 1000000; | |
void setup() { | |
Serial.begin(115200); | |
pinMode(LED_BUILTIN, OUTPUT); | |
delay(1000); | |
Serial.print("Size of Int: "); | |
Serial.println(sizeof(y)); | |
Serial.print("Size of Float: "); | |
Serial.println(sizeof(z)); | |
Serial.print("Size of Long: "); | |
Serial.println(sizeof(loops)); | |
} | |
void loop() { | |
start = millis(); | |
for(long w=0;w<10000;w++) { | |
sensorValue = analogRead(A0); | |
} | |
Serial.print("ADC," + board + ","); | |
Serial.println(millis() - start); | |
//int test | |
start = millis(); | |
for(long x=0;x<loops;x++) { | |
y = y+x; | |
} | |
Serial.print("Int Sum," + board + ","); | |
Serial.print(millis() - start); | |
Serial.print(","); | |
Serial.println(y); | |
//int mult test | |
start = millis(); | |
y=3; | |
for(long x=0;x<loops;x++) { | |
y = y*2; | |
if (y>1000) { y=1; } | |
} | |
Serial.print("Int mult," + board + ","); | |
Serial.print(millis() - start); | |
Serial.print(","); | |
Serial.println(y); | |
z=0; | |
start = millis(); | |
for(long w=0;w<loops;w++) { | |
z = z+1; | |
} | |
Serial.print("Float Sum," + board + ","); | |
Serial.print(millis() - start); | |
Serial.print(","); | |
Serial.println(z); | |
z=1; | |
start = millis(); | |
for(long w=0;w<loops;w++) { | |
z = z*1.1; | |
if (z > 1000) { z = 1.1; } | |
} | |
Serial.print("Float multi," + board + ","); | |
Serial.print(millis() - start); | |
Serial.print(","); | |
Serial.println(z); | |
z=1; | |
start = millis(); | |
for(long w=1;w<loops;w++) { | |
z = w/1.1 + z; | |
if (z > 1000) { z=1;} | |
} | |
Serial.print("Float divide," + board + ","); | |
Serial.print(millis() - start); | |
Serial.print(","); | |
Serial.println(z); | |
//gpio test | |
start = millis(); | |
for(long w=0;w<loops;w++) { | |
digitalWrite(LED_BUILTIN, HIGH); | |
digitalWrite(LED_BUILTIN, LOW); | |
} | |
Serial.print("GPIO test," + board + ","); | |
Serial.println(millis() - start); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment