2020-11-27 05:20:37 -05:00
|
|
|
//
|
|
|
|
// FILE: multimap_timing.ino
|
|
|
|
// AUTHOR: Rob Tillaart
|
|
|
|
// PURPOSE: demo
|
|
|
|
// DATE: 2020-04-09
|
|
|
|
// (c) : MIT
|
|
|
|
//
|
2021-12-22 06:10:05 -05:00
|
|
|
// example measures the performance of multiMap <int> vs <float>
|
2020-11-27 05:20:37 -05:00
|
|
|
|
|
|
|
|
2021-01-29 06:31:58 -05:00
|
|
|
#include "MultiMap.h"
|
2020-11-27 05:20:37 -05:00
|
|
|
|
|
|
|
int in[] = { 11, 22, 33};
|
|
|
|
int out[] = {111, 222, 555};
|
|
|
|
|
|
|
|
float fin[] = { 11, 22, 33};
|
|
|
|
float fout[] = {111, 222, 555};
|
|
|
|
|
|
|
|
uint32_t start;
|
|
|
|
uint32_t stop;
|
|
|
|
|
2021-05-28 07:39:42 -04:00
|
|
|
|
2020-11-27 05:20:37 -05:00
|
|
|
void setup()
|
|
|
|
{
|
|
|
|
Serial.begin(115200);
|
|
|
|
Serial.println(__FILE__);
|
|
|
|
Serial.println();
|
|
|
|
delay(10); // make sure print has ended
|
|
|
|
|
|
|
|
start = micros();
|
|
|
|
float x = multiMap<int>(12, in, out, 3);
|
|
|
|
stop = micros();
|
2021-12-22 06:10:05 -05:00
|
|
|
Serial.print("time <int>: \t");
|
2020-11-27 05:20:37 -05:00
|
|
|
Serial.println(stop - start);
|
|
|
|
Serial.println(x, 4);
|
|
|
|
delay(10); // make sure print has ended
|
|
|
|
|
|
|
|
start = micros();
|
|
|
|
float y = multiMap<float>(12, fin, fout, 3);
|
|
|
|
stop = micros();
|
2021-12-22 06:10:05 -05:00
|
|
|
Serial.print("time <float>: \t");
|
2020-11-27 05:20:37 -05:00
|
|
|
Serial.println(stop - start);
|
|
|
|
Serial.println(y, 4);
|
2021-12-22 06:10:05 -05:00
|
|
|
delay(10); // make sure print has ended
|
|
|
|
|
|
|
|
Serial.println("\ndone...");
|
2020-11-27 05:20:37 -05:00
|
|
|
}
|
|
|
|
|
2021-05-28 07:39:42 -04:00
|
|
|
|
2020-11-27 05:20:37 -05:00
|
|
|
void loop()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-05-28 07:39:42 -04:00
|
|
|
|
2020-11-27 05:20:37 -05:00
|
|
|
// -- END OF FILE --
|
2021-12-22 06:10:05 -05:00
|
|
|
|