runners: A number of stack/heap measurement tweaks
- Renamed BENCH_STACK/HEAP -> BENCH_STACK/HEAP_WATERMARK
- Renamed BENCH_YES_STACK/HEAP -> BENCH_STACK/HEAP
- Tweaked stack/heap watermarks to hopefully be easier to access when
debugging. Now also exposed as global variables
(bench_stack/heap_watermark).
I considered changing BENCH_STACK/HEAP_WATERMARK to be the variable
itself, to be consistent with TEST_PLS, but decided against it:
1. BENCH_STACK_CURRENT() is a bit magic in that it relies on
__attribute__((noinline)) to force a new stack frame. This wouldn't
really be possible with a variable.
2. TEST_PLS is at least constant from the _current run_'s perspective.
This isn't true for the stack/heap watermarks.
- Reworked internals a bit to hopefully be simpler
This commit is contained in:
+20
-12
@@ -138,36 +138,44 @@ void test_permutation(size_t i, uint32_t *buffer, size_t size);
|
||||
#define TEST_FACTORIAL(x) test_factorial(x)
|
||||
#define TEST_PERMUTATION(i, buffer, size) test_permutation(i, buffer, size)
|
||||
|
||||
#ifdef TEST_YES_STACK
|
||||
#ifdef TEST_STACK
|
||||
// get the maximum/current stack usage for this run
|
||||
size_t test_stack(void);
|
||||
__attribute__((noinline))
|
||||
size_t test_stack_current(void);
|
||||
__attribute__((noinline))
|
||||
void test_stack_pause(void);
|
||||
extern size_t test_stack_watermark;
|
||||
__attribute__((noinline)) size_t test_stack_current(void);
|
||||
__attribute__((noinline)) void test_stack_pause(void);
|
||||
void test_stack_resume(void);
|
||||
|
||||
#define TEST_STACK() test_stack()
|
||||
#define TEST_STACK_WATERMARK() test_stack_watermark
|
||||
#define TEST_STACK_CURRENT() test_stack_current()
|
||||
#define TEST_STACK_PAUSE() test_stack_pause()
|
||||
#define TEST_STACK_RESUME() test_stack_resume()
|
||||
#else
|
||||
// stubs if not measuring stack
|
||||
#define TEST_STACK_PAUSE()
|
||||
#define TEST_STACK_RESUME()
|
||||
#endif
|
||||
|
||||
#ifdef TEST_YES_HEAP
|
||||
#ifdef TEST_HEAP
|
||||
// get the maximum/current heap usage for this run
|
||||
size_t test_heap(void);
|
||||
size_t test_heap_current(void);
|
||||
extern size_t test_heap_watermark;
|
||||
extern size_t test_heap_current;
|
||||
void test_heap_pause(void);
|
||||
void test_heap_resume(void);
|
||||
void test_heap_inc(size_t size);
|
||||
void test_heap_dec(size_t size);
|
||||
|
||||
#define TEST_HEAP() test_heap()
|
||||
#define TEST_HEAP_CURRENT() test_heap_current()
|
||||
#define TEST_HEAP_WATERMARK() test_heap_watermark
|
||||
#define TEST_HEAP_CURRENT() test_heap_current
|
||||
#define TEST_HEAP_PAUSE() test_heap_pause()
|
||||
#define TEST_HEAP_RESUME() test_heap_resume()
|
||||
#define TEST_HEAP_INC(size) test_heap_inc(size)
|
||||
#define TEST_HEAP_DEC(size) test_heap_dec(size)
|
||||
#else
|
||||
// stubs if not measuring heap
|
||||
#define TEST_HEAP_PAUSE()
|
||||
#define TEST_HEAP_RESUME()
|
||||
#define TEST_HEAP_INC(size)
|
||||
#define TEST_HEAP_DEC(size)
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user