GY-63_MS5611/libraries/Kelvin2RGB/examples/Kelvin2RGB_timing/Kelvin2RGB_timing.ino

70 lines
1.1 KiB
Arduino
Raw Normal View History

2021-01-29 06:31:58 -05:00
//
// FILE: Kelvin2RGB_timing.ino
// AUTHOR: Rob Tillaart
// PURPOSE: demo - shows timing 2 methods
// DATE: 2020-07-29
// URL: https://github.com/RobTillaart/Kelvin2RGB
#include "Kelvin2RGB.h"
Kelvin2RGB KRGB;
2021-11-06 10:56:44 -04:00
uint32_t start, stop, duration1, duration2;
2021-01-29 06:31:58 -05:00
void setup()
{
Serial.begin(115200);
Serial.println(__FILE__);
KRGB.begin();
test_timing();
2021-12-20 11:09:35 -05:00
2021-11-06 10:56:44 -04:00
Serial.println("\ndone...");
2021-01-29 06:31:58 -05:00
}
2021-11-06 10:56:44 -04:00
2021-01-29 06:31:58 -05:00
void loop()
{
}
2021-11-06 10:56:44 -04:00
2021-01-29 06:31:58 -05:00
void test_timing()
{
Serial.println(__FUNCTION__);
Serial.println();
// volatile to minimize optimization
volatile float bright = 100.0;
volatile float temp = 6500.0;
start = micros();
for (int i = 0; i < 1000; i++)
{
KRGB.convert_TH(temp, bright);
}
stop = micros();
2021-11-06 10:56:44 -04:00
duration1 = stop - start;
2021-01-29 06:31:58 -05:00
start = micros();
for (int i = 0; i < 1000; i++)
{
KRGB.convert_NB(temp, bright);
}
stop = micros();
2021-11-06 10:56:44 -04:00
duration2 = stop - start;
2021-01-29 06:31:58 -05:00
Serial.print("TH:\t");
2021-11-06 10:56:44 -04:00
Serial.println(duration1 * 0.001);
2021-01-29 06:31:58 -05:00
Serial.print("NB:\t");
2021-11-06 10:56:44 -04:00
Serial.println(duration2 * 0.001);
2021-01-29 06:31:58 -05:00
Serial.print("ratio:\t");
2021-11-06 10:56:44 -04:00
Serial.println(1.0 * duration1 / duration2, 4);
2021-01-29 06:31:58 -05:00
}
2021-11-06 10:56:44 -04:00
2021-01-29 06:31:58 -05:00
// -- END OF FILE --
2021-11-06 10:56:44 -04:00