GY-63_MS5611/libraries/BoolArray/examples/boolArrayDemo2/boolArrayDemo2.ino

159 lines
2.7 KiB
Arduino
Raw Normal View History

//
// FILE: boolArrayDemo2.ino
// AUTHOR: Rob Tillaart
2017-04-28 04:34:30 -04:00
// PURPOSE: demo performance boolean array
// DATE: 2015-12-12
2023-02-08 11:14:17 -05:00
// URL: https://github.com/RobTillaart/BoolArray
2021-01-29 06:31:58 -05:00
#include "BoolArray.h"
2021-01-29 06:31:58 -05:00
BoolArray b;
uint32_t start;
uint32_t stop;
volatile long x = 0;
2021-01-29 06:31:58 -05:00
void setup()
{
Serial.begin(115200);
Serial.print("Start ");
Serial.println(__FILE__);
2017-04-28 04:34:30 -04:00
Serial.print("BOOLARRAY_LIB_VERSION:\t");
Serial.println(BOOLARRAY_LIB_VERSION);
b.begin(1000);
2020-11-27 05:10:47 -05:00
Serial.print("Bool array size:\t");
Serial.println(b.size());
2017-04-28 04:34:30 -04:00
Serial.println("\nget");
2023-02-08 11:14:17 -05:00
delay(10);
start = micros();
for (int i = 0; i < 1000; i++)
{
x += b.get(i);
}
stop = micros();
Serial.print("DURATION:\t");
Serial.println(stop - start);
2023-02-08 11:14:17 -05:00
delay(10);
start = micros();
for (int i = 0; i < 1000; i++)
{
x += b.get(i);
x += b.get(i);
}
stop = micros();
Serial.print("DURATION:\t");
Serial.println(stop - start);
Serial.print(" X:\t");
Serial.println(x);
2017-04-28 04:34:30 -04:00
Serial.println("\nset");
2023-02-08 11:14:17 -05:00
delay(10);
start = micros();
for (int i = 0; i < 1000; i++)
{
b.set(i, 0);
}
stop = micros();
Serial.print("DURATION:\t");
Serial.println(stop - start);
2023-02-08 11:14:17 -05:00
delay(10);
start = micros();
for (int i = 0; i < 1000; i++)
{
b.set(i, 0);
b.set(i, 0);
}
stop = micros();
Serial.print("DURATION:\t");
Serial.println(stop - start);
2017-04-28 04:34:30 -04:00
Serial.println("\nclear");
2023-02-08 11:14:17 -05:00
delay(10);
start = micros();
for (int i = 0; i < 1000; i++)
{
b.clear();
}
stop = micros();
Serial.print("DURATION:\t");
Serial.println(stop - start);
2023-02-08 11:14:17 -05:00
delay(10);
start = micros();
for (int i = 0; i < 1000; i++)
{
b.clear();
b.clear();
}
stop = micros();
Serial.print("DURATION:\t");
Serial.println(stop - start);
2017-04-28 04:34:30 -04:00
Serial.println("\nsetAll");
2023-02-08 11:14:17 -05:00
delay(10);
start = micros();
for (int i = 0; i < 1000; i++)
{
b.setAll(1);
}
stop = micros();
Serial.print("DURATION:\t");
Serial.println(stop - start);
2020-11-27 05:10:47 -05:00
for (int i = 0; i < 1000; i++)
{
2023-02-08 11:14:17 -05:00
if (b.get(i) == 0) Serial.println("Error in clear()");
2020-11-27 05:10:47 -05:00
}
2023-02-08 11:14:17 -05:00
delay(10);
2020-11-27 05:10:47 -05:00
start = micros();
for (int i = 0; i < 1000; i++)
{
b.setAll(1);
b.setAll(1);
}
stop = micros();
Serial.print("DURATION:\t");
Serial.println(stop - start);
2017-04-28 04:34:30 -04:00
Serial.println("\ntoggle");
2023-02-08 11:14:17 -05:00
delay(10);
2017-04-28 04:34:30 -04:00
start = micros();
for (int i = 0; i < 1000; i++)
{
b.toggle(i);
}
stop = micros();
Serial.print("DURATION:\t");
Serial.println(stop - start);
2023-02-08 11:14:17 -05:00
delay(10);
2017-04-28 04:34:30 -04:00
start = micros();
for (int i = 0; i < 1000; i++)
{
b.toggle(i);
b.toggle(i);
}
stop = micros();
Serial.print("DURATION:\t");
Serial.println(stop - start);
Serial.println("Done...");
}
2021-01-29 06:31:58 -05:00
void loop()
{
2021-01-29 06:31:58 -05:00
}
2021-12-14 08:48:42 -05:00
2023-02-08 11:14:17 -05:00
// -- END OF FILE --