GY-63_MS5611/libraries/BitArray/examples/bitArrayDemo3/bitArrayDemo3.ino

138 lines
2.6 KiB
Arduino
Raw Normal View History

2017-07-16 07:39:43 -04:00
//
// FILE: bitArrayDemo3.ino
// AUTHOR: Rob Tillaart
// VERSION: 0.1.0
// PURPOSE: demo performance reading boolean array
// DATE: 2017-07-15
2021-10-19 10:11:27 -04:00
// URL: https://github.com/RobTillaart/BitArray
2017-07-16 07:39:43 -04:00
// URL: https://forum.arduino.cc/index.php?topic=361167.0
//
2021-10-19 10:11:27 -04:00
2017-07-16 07:39:43 -04:00
#include "BitArray.h"
BitArray b;
uint32_t start;
uint32_t stop;
volatile int32_t x = 0;
2021-10-19 10:11:27 -04:00
2017-07-16 07:39:43 -04:00
void setup()
{
Serial.begin(115200);
Serial.print("Start ");
Serial.println(__FILE__);
Serial.print("LIB VERSION:\t");
Serial.println(BITARRAY_LIB_VERSION);
test(1, 10000);
test(2, 5000);
test(3, 3333);
test(4, 2500);
}
2021-10-19 10:11:27 -04:00
2017-07-16 07:39:43 -04:00
void test(uint8_t bits, uint16_t cnt)
{
b.begin(bits, cnt);
Serial.print("CAPACITY:\t");
Serial.println(b.capacity());
Serial.print(" MEMORY:\t");
Serial.println(b.memory());
Serial.print(" BITS:\t");
Serial.println(b.bits());
Serial.print("SEGMENTS:\t");
Serial.println(b.segments());
delay(100);
Serial.println("\nGET:");
start = micros();
for (uint16_t i = 0; i < cnt; i++)
{
x += b.get(i);
}
stop = micros();
Serial.print("DURATION:\t");
Serial.println(stop - start);
delay(100);
start = micros();
for (uint16_t i = 0; i < cnt; 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);
delay(100);
Serial.println("\nSET:");
start = micros();
for (uint16_t i = 0; i < cnt; i++)
{
b.set(i, 0);
}
stop = micros();
Serial.print("DURATION:\t");
Serial.println(stop - start);
delay(100);
start = micros();
for (uint16_t i = 0; i < cnt; i++)
{
b.set(i, 0);
b.set(i, 0);
}
stop = micros();
Serial.print("DURATION:\t");
Serial.println(stop - start);
delay(100);
Serial.println("\nCLEAR:");
start = micros();
b.clear();
stop = micros();
Serial.print("DURATION:\t");
Serial.println(stop - start);
delay(100);
Serial.println("\nTOGGLE:");
start = micros();
for (uint16_t i = 0; i < cnt; i++)
{
b.toggle(i);
}
stop = micros();
Serial.print("DURATION:\t");
Serial.println(stop - start);
delay(100);
start = micros();
for (uint16_t i = 0; i < cnt; i++)
{
b.toggle(i);
b.toggle(i);
}
stop = micros();
Serial.print("DURATION:\t");
Serial.println(stop - start);
delay(100);
Serial.println("Done...");
}
2021-10-19 10:11:27 -04:00
2017-07-16 07:39:43 -04:00
void loop()
{
2021-10-19 10:11:27 -04:00
}
// -- END OF FILE --