Skip to content

Commit b7804da

Browse files
committed
Expose TimeTrace::Buffer::BUFFER_SIZE_EXP as a preprocessor macro
Users can configure the buffer size at compile-time by typing make MACROS=-DTIMETRACE_BUFFER_SIZE_EXP=17
1 parent 93c4594 commit b7804da

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

Diff for: Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ SRC_DIR = src
77
WRAPPER_DIR = cwrapper
88
INCLUDE_DIR = $(DESTDIR)/include
99
LIB_DIR = $(DESTDIR)/lib
10-
CXXFLAGS=-O3 -DNDEBUG -fPIC -std=c++11 -pthread
11-
CFLAGS=-O3 -DNDEBUG -fPIC -std=gnu99
10+
CXXFLAGS = $(MACROS) -O3 -DNDEBUG -fPIC -std=c++11 -pthread
11+
CFLAGS = $(MACROS) -O3 -DNDEBUG -fPIC -std=gnu99
1212
INCLUDE=-I$(SRC_DIR)
1313

1414
# Stuff needed for make check

Diff for: src/TimeTrace.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,8 @@ TimeTrace::printInternal(std::vector<TimeTrace::Buffer*>* buffers, string* s) {
337337
// by the sheer size of the cycle counter.
338338
char message[200];
339339
snprintf(message, sizeof(message),
340-
"CYCLES_PER_SECOND %f\nSTART_CYCLES %lu\n",
341-
Cycles::perSecond(), startTime);
340+
"CYCLES_PER_SECOND %f\nSTART_CYCLES %lu\nBUFFER_SIZE %u\n",
341+
Cycles::perSecond(), startTime, Buffer::BUFFER_SIZE);
342342
if (s != NULL) {
343343
s->append(message);
344344
} else {

Diff for: src/TimeTrace.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@
2424
#include "Atomic.h"
2525
#include "Cycles.h"
2626

27+
#ifndef TIMETRACE_BUFFER_SIZE_EXP
28+
#define TIMETRACE_BUFFER_SIZE_EXP 13
29+
#endif
30+
2731
namespace PerfUtils {
2832

2933
// A macro to disallow the copy constructor and operator= functions
@@ -173,7 +177,7 @@ class TimeTrace {
173177

174178
protected:
175179
// Determines the number of events we can retain as an exponent of 2
176-
static const uint8_t BUFFER_SIZE_EXP = 13;
180+
static const uint8_t BUFFER_SIZE_EXP = TIMETRACE_BUFFER_SIZE_EXP;
177181

178182
// Total number of events that we can retain any given time.
179183
static const uint32_t BUFFER_SIZE = 1 << BUFFER_SIZE_EXP;

0 commit comments

Comments
 (0)