22// FILE: nibbleArray_performance.ino
33// AUTHOR: Rob Tillaart
44// PURPOSE: demo performance nibble array
5- // DATE: 2020-06-21
65// URL: https://github.com/RobTillaart/nibbleArray
76
87
98#include " nibbleArray.h"
109
1110
12- // AVR UNO can handle only 510
13- // ESP32 can do more but depends on RTOS limits
11+ // AVR UNO can handle only 510
12+ // ESP32 can do more but depends on RTOS limits
13+
1414
1515#define NA_SIZE 500
1616
@@ -23,13 +23,16 @@ volatile long x = 0;
2323void setup ()
2424{
2525 Serial.begin (115200 );
26+ Serial.println ();
2627 Serial.println (__FILE__);
2728 Serial.print (" NIBBLEARRAY_LIB_VERSION: " );
2829 Serial.println (NIBBLEARRAY_LIB_VERSION );
30+ Serial.println ();
31+ delay (100 );
2932
30- // performance tests are run first once in a loop
31- // then twice in a loop, so the difference is without
32- // the loop overhead.
33+ // performance tests are run first once in a loop
34+ // then twice in a loop, so the difference is without
35+ // the loop overhead.
3336 test_size ();
3437 test_get ();
3538 test_set ();
@@ -42,6 +45,10 @@ void setup()
4245
4346void test_size ()
4447{
48+ Serial.println ();
49+ Serial.println (__FUNCTION__);
50+ delay (10 );
51+
4552 Serial.print (" Nibble array size:\t " );
4653 Serial.println (na.size ());
4754 Serial.print (" Nibble array mem:\t " );
@@ -52,8 +59,10 @@ void test_size()
5259
5360void test_get ()
5461{
55- Serial.println (" \n get" );
62+ Serial.println ();
63+ Serial.println (__FUNCTION__);
5664 delay (10 );
65+
5766 start = micros ();
5867 for (uint16_t i = 0 ; i < na.size (); i++)
5968 {
@@ -85,8 +94,10 @@ void test_get()
8594
8695void test_set ()
8796{
88- Serial.println (" \n set" );
97+ Serial.println ();
98+ Serial.println (__FUNCTION__);
8999 delay (10 );
100+
90101 start = micros ();
91102 for (uint16_t i = 0 ; i < na.size (); i++)
92103 {
@@ -116,8 +127,10 @@ void test_set()
116127
117128void test_clear ()
118129{
119- Serial.println (" \n clear" );
130+ Serial.println ();
131+ Serial.println (__FUNCTION__);
120132 delay (10 );
133+
121134 start = micros ();
122135 na.clear ();
123136 stop = micros ();
@@ -136,6 +149,7 @@ void test_clear()
136149 Serial.print (" DELTA:\t\t " );
137150 Serial.println (d2 - d1);
138151 delay (100 );
152+
139153 for (uint16_t i = 0 ; i < na.size (); i++)
140154 {
141155 if (na.get (i) != 0 )
@@ -149,15 +163,18 @@ void test_clear()
149163
150164void test_setAll ()
151165{
152- Serial.println (" \n setAll" );
166+ Serial.println ();
167+ Serial.println (__FUNCTION__);
153168 delay (10 );
169+
154170 start = micros ();
155171 na.setAll (1 );
156172 stop = micros ();
157173 Serial.print (" DURATION:\t " );
158174 d1 = stop - start;
159175 Serial.println (d1);
160176 delay (100 );
177+
161178 for (uint16_t i = 0 ; i < na.size (); i++)
162179 {
163180 if (na.get (i) != 1 )
0 commit comments