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

104 lines
2.0 KiB
Arduino
Raw Normal View History

//
// FILE: bitArrayDemo2.ino
// AUTHOR: Rob Tillaart
2021-10-19 10:11:27 -04:00
// VERSION: 0.1.3
// PURPOSE: demo performance reading boolean array
// DATE: 2015-12-06
2021-10-19 10:11:27 -04:00
// URL: https://github.com/RobTillaart/BitArray
// URL: https://forum.arduino.cc/index.php?topic=361167.0
//
2021-10-19 10:11:27 -04:00
#include "BitArray.h"
BitArray b;
uint32_t start;
uint32_t stop;
2017-07-16 07:39:43 -04:00
volatile int32_t x = 0;
2021-10-19 10:11:27 -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);
2015-12-09 15:59:28 -05: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);
2015-12-09 15:59:28 -05:00
start = micros();
2017-07-16 07:39:43 -04:00
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();
2017-07-16 07:39:43 -04:00
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);
start = micros();
2017-07-16 07:39:43 -04:00
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();
2017-07-16 07:39:43 -04:00
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);
start = micros();
b.clear();
stop = micros();
Serial.print("DURATION:\t");
Serial.println(stop - start);
delay(100);
Serial.println("Done...");
}
void loop()
{
2015-12-09 15:59:28 -05:00
}