Skip to content

Commit

Permalink
Expose TimeTrace::Buffer::BUFFER_SIZE_EXP as a preprocessor macro
Browse files Browse the repository at this point in the history
Users can configure the buffer size at compile-time by typing
    make MACROS=-DTIMETRACE_BUFFER_SIZE_EXP=17
  • Loading branch information
yilongli committed Nov 17, 2018
1 parent 93c4594 commit b7804da
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ SRC_DIR = src
WRAPPER_DIR = cwrapper
INCLUDE_DIR = $(DESTDIR)/include
LIB_DIR = $(DESTDIR)/lib
CXXFLAGS=-O3 -DNDEBUG -fPIC -std=c++11 -pthread
CFLAGS=-O3 -DNDEBUG -fPIC -std=gnu99
CXXFLAGS = $(MACROS) -O3 -DNDEBUG -fPIC -std=c++11 -pthread
CFLAGS = $(MACROS) -O3 -DNDEBUG -fPIC -std=gnu99
INCLUDE=-I$(SRC_DIR)

# Stuff needed for make check
Expand Down
4 changes: 2 additions & 2 deletions src/TimeTrace.cc
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,8 @@ TimeTrace::printInternal(std::vector<TimeTrace::Buffer*>* buffers, string* s) {
// by the sheer size of the cycle counter.
char message[200];
snprintf(message, sizeof(message),
"CYCLES_PER_SECOND %f\nSTART_CYCLES %lu\n",
Cycles::perSecond(), startTime);
"CYCLES_PER_SECOND %f\nSTART_CYCLES %lu\nBUFFER_SIZE %u\n",
Cycles::perSecond(), startTime, Buffer::BUFFER_SIZE);
if (s != NULL) {
s->append(message);
} else {
Expand Down
6 changes: 5 additions & 1 deletion src/TimeTrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
#include "Atomic.h"
#include "Cycles.h"

#ifndef TIMETRACE_BUFFER_SIZE_EXP
#define TIMETRACE_BUFFER_SIZE_EXP 13
#endif

namespace PerfUtils {

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

protected:
// Determines the number of events we can retain as an exponent of 2
static const uint8_t BUFFER_SIZE_EXP = 13;
static const uint8_t BUFFER_SIZE_EXP = TIMETRACE_BUFFER_SIZE_EXP;

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

0 comments on commit b7804da

Please sign in to comment.