Opportunistically use perftools if installed.

Allows us to collect profiles of the open source build using gprof.
pull/70/head
Craig Tiller 10 years ago
parent fbf4051ef2
commit 297fafa078
  1. 13
      .gitignore
  2. 7
      Makefile
  3. 7
      templates/Makefile.template
  4. 7
      test/build/perftools.c
  5. 9
      test/core/util/grpc_profiler.c

13
.gitignore vendored

@ -1,8 +1,15 @@
# C/C++ build outputs
bins
coverage
deps
*.gcno
gens
libs
objs
# gcov coverage data
coverage
*.gcno
# profiler output
*.prof
# python compiled objects
*.pyc

@ -172,6 +172,13 @@ endif
OPENSSL_ALPN_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o /dev/null test/build/openssl-alpn.c -lssl -lcrypto -ldl $(LDFLAGS)
ZLIB_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o /dev/null test/build/zlib.c -lz $(LDFLAGS)
PERFTOOLS_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o /dev/null test/build/perftools.c -lprofiler $(LDFLAGS)
HAS_SYSTEM_PERFTOOLS = $(shell $(PERFTOOLS_CHECK_CMD) 2> /dev/null && echo true || echo false)
ifeq ($(HAS_SYSTEM_PERFTOOLS),true)
DEFINES += GRPC_HAVE_PERFTOOLS
LIBS += profiler
endif
ifndef REQUIRE_CUSTOM_LIBRARIES_$(CONFIG)
HAS_SYSTEM_OPENSSL_ALPN = $(shell $(OPENSSL_ALPN_CHECK_CMD) 2> /dev/null && echo true || echo false)

@ -189,6 +189,13 @@ endif
OPENSSL_ALPN_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o /dev/null test/build/openssl-alpn.c -lssl -lcrypto -ldl $(LDFLAGS)
ZLIB_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o /dev/null test/build/zlib.c -lz $(LDFLAGS)
PERFTOOLS_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o /dev/null test/build/perftools.c -lprofiler $(LDFLAGS)
HAS_SYSTEM_PERFTOOLS = $(shell $(PERFTOOLS_CHECK_CMD) 2> /dev/null && echo true || echo false)
ifeq ($(HAS_SYSTEM_PERFTOOLS),true)
DEFINES += GRPC_HAVE_PERFTOOLS
LIBS += profiler
endif
ifndef REQUIRE_CUSTOM_LIBRARIES_$(CONFIG)
HAS_SYSTEM_OPENSSL_ALPN = $(shell $(OPENSSL_ALPN_CHECK_CMD) 2> /dev/null && echo true || echo false)

@ -0,0 +1,7 @@
#include <gperftools/profiler.h>
int main() {
ProfilerStart("/dev/null");
ProfilerStop();
return 0;
}

@ -33,6 +33,15 @@
#include "test/core/util/grpc_profiler.h"
#if GRPC_HAVE_PERFTOOLS
#include <gperftools/profiler.h>
void grpc_profiler_start(const char *filename) { ProfilerStart(filename); }
void grpc_profiler_stop() { ProfilerStop(); }
#else
void grpc_profiler_start(const char *filename) {}
void grpc_profiler_stop(void) {}
#endif

Loading…
Cancel
Save