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

151 lines
2.6 KiB
Arduino
Raw Normal View History

//
// FILE: boolArrayDemo2.ino
// AUTHOR: Rob Tillaart
2017-04-28 04:34:30 -04:00
// VERSION: 0.1.1
// PURPOSE: demo performance boolean array
// DATE: 2015-12-12
// URL: https://forum.arduino.cc/index.php?topic=361167.0
//
2017-04-28 04:34:30 -04:00
// 0.1.1 - added performance for toggle
//
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");
start = micros();
for (int i = 0; i < 1000; i++)
{
x += b.get(i);
}
stop = micros();
Serial.print("DURATION:\t");
Serial.println(stop - start);
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");
start = micros();
for (int i = 0; i < 1000; i++)
{
b.set(i, 0);
}
stop = micros();
Serial.print("DURATION:\t");
Serial.println(stop - start);
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");
start = micros();
for (int i = 0; i < 1000; i++)
{
b.clear();
}
stop = micros();
Serial.print("DURATION:\t");
Serial.println(stop - start);
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");
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++)
{
if (b.get(i) == 0) Serial.println("Error in CLr()");
}
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");
start = micros();
for (int i = 0; i < 1000; i++)
{
b.toggle(i);
}
stop = micros();
Serial.print("DURATION:\t");
Serial.println(stop - start);
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
}
// -- END OF FILE --