-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathMemoryBenchmark.ino
69 lines (58 loc) · 1.78 KB
/
MemoryBenchmark.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
* Determine the flash and static memory consumption of a minimal AUnit test.
*/
#include <stdint.h> // uint8_t
#include <Arduino.h>
// List of features of the AUnit library that we want to examine.
#define FEATURE_BASELINE 0
#define FEATURE_AUNIT 1
#define FEATURE_AUNIT_VERBOSE 2
// Select one of the FEATURE_* parameter and compile. Then look at the flash
// and RAM usage, compared to FEATURE_BASELINE usage to determine how much
// flash and RAM is consumed by the selected feature.
// NOTE: This line is modified by a 'sed' script in collect.sh. Be careful
// when modifying its format.
#define FEATURE 0
#if FEATURE == FEATURE_AUNIT
#include <AUnit.h>
using namespace aunit;
#elif FEATURE == FEATURE_AUNIT_VERBOSE
#include <AUnitVerbose.h>
using namespace aunit;
#endif
// Define SERIAL_PORT_MONITOR for ESP32
#ifndef SERIAL_PORT_MONITOR
#define SERIAL_PORT_MONITOR Serial
#endif
// Set this variable to prevent the compiler optimizer from removing the code
// being tested when it determines that it does nothing.
volatile uint8_t guard;
// Define one unit test if FEATURE_AUNIT is enabled.
#if FEATURE == FEATURE_BASELINE
// pass
#elif FEATURE == FEATURE_AUNIT || FEATURE == FEATURE_AUNIT_VERBOSE
test(atest) {
guard = 1;
assertEqual(1, guard);
}
#else
#error Unknown FEATURE
#endif
void setup() {
#if ! defined(EPOXY_DUINO)
delay(2000);
#endif
// Setup the Serial, to force inclusion of the Print class in the Baseline, so
// that we can measure the incremental amount of code brought in by PrintStr<>
// and PrintStrN<>.
SERIAL_PORT_MONITOR.begin(115200);
while (! SERIAL_PORT_MONITOR); // Leonardo/Micro
#if defined(EPOXY_DUINO)
SERIAL_PORT_MONITOR.setLineModeUnix();
#endif
}
void loop() {
#if FEATURE != FEATURE_BASELINE
aunit::TestRunner::run();
#endif
}