mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-10-03 18:09:02 -04:00
0.1.4 FastShiftInOut
This commit is contained in:
parent
9291dc2491
commit
625aa03944
@ -0,0 +1,100 @@
|
||||
//
|
||||
// FILE: fastMap_performance_test.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// PURPOSE: demo of FastMap class ==> a faster map function
|
||||
// DATE: 2014-11-02
|
||||
// URL: https://github.com/RobTillaart/FastMap
|
||||
|
||||
|
||||
#include "FastMap.h"
|
||||
|
||||
uint32_t start;
|
||||
uint32_t stop;
|
||||
uint32_t reference;
|
||||
|
||||
volatile long zz = 3000, yy = 20000;
|
||||
volatile float x;
|
||||
volatile int z;
|
||||
|
||||
FastMap mapper;
|
||||
FastMapDouble mapperD;
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
Serial.println();
|
||||
Serial.println(__FILE__);
|
||||
Serial.print("FASTMAP_LIB_VERSION: ");
|
||||
Serial.println(FASTMAP_LIB_VERSION);
|
||||
Serial.println();
|
||||
delay(100);
|
||||
|
||||
// Get a non optimizable value;
|
||||
z = analogRead(A0);
|
||||
|
||||
|
||||
// REFERENCE
|
||||
start = micros();
|
||||
for (int i = 0; i < 10000; i++)
|
||||
{
|
||||
x = map(z, 0, 1023, yy, zz);
|
||||
}
|
||||
stop = micros();
|
||||
reference = stop - start;
|
||||
Serial.print("MAP:\t");
|
||||
Serial.println(reference);
|
||||
Serial.print(z);
|
||||
Serial.print(" -> ");
|
||||
Serial.println(x);
|
||||
Serial.println();
|
||||
delay(100);
|
||||
|
||||
|
||||
|
||||
// FASTMAP
|
||||
mapper.init(0, 1023, yy, zz);
|
||||
start = micros();
|
||||
for (int i = 0; i < 10000; i++)
|
||||
{
|
||||
x = mapper.map(z);
|
||||
}
|
||||
stop = micros();
|
||||
Serial.print("FASTMAP:\t");
|
||||
Serial.println(stop - start);
|
||||
Serial.print(z);
|
||||
Serial.print(" -> ");
|
||||
Serial.println(x);
|
||||
Serial.print("Performance factor: ");
|
||||
Serial.println(1.0 * reference / (stop - start));
|
||||
Serial.println();
|
||||
delay(100);
|
||||
|
||||
|
||||
|
||||
// FASTMAPDOUBLE
|
||||
mapperD.init(0, 1023, yy, zz);
|
||||
start = micros();
|
||||
for (int i = 0; i < 10000; i++)
|
||||
{
|
||||
x = mapperD.map(z);
|
||||
}
|
||||
stop = micros();
|
||||
Serial.print("FASTMAPD:\t");
|
||||
Serial.println(stop - start);
|
||||
Serial.print(z);
|
||||
Serial.print(" -> ");
|
||||
Serial.println(x);
|
||||
Serial.print("Performance factor: ");
|
||||
Serial.println(1.0 * reference / (stop - start));
|
||||
Serial.println();
|
||||
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
@ -0,0 +1,13 @@
|
||||
fastMap_performance_test.ino
|
||||
FASTMAP_LIB_VERSION: 0.4.1
|
||||
|
||||
MAP: 1814
|
||||
0 -> 20000.00
|
||||
|
||||
FASTMAP: 627
|
||||
0 -> 20000.00
|
||||
Performance factor: 2.89
|
||||
|
||||
FASTMAPD: 6924
|
||||
0 -> 20000.00
|
||||
Performance factor: 0.26
|
@ -0,0 +1,14 @@
|
||||
|
||||
fastMap_performance_test.ino
|
||||
FASTMAP_LIB_VERSION: 0.4.1
|
||||
|
||||
MAP: 496072
|
||||
1023 -> 3000.00
|
||||
|
||||
FASTMAP: 211888
|
||||
1023 -> 3000.00
|
||||
Performance factor: 2.34
|
||||
|
||||
FASTMAPD: 211888
|
||||
1023 -> 3000.00
|
||||
Performance factor: 2.34
|
Loading…
Reference in New Issue
Block a user