mirror of
https://github.com/matrix-construct/construct
synced 2024-11-25 08:12:37 +01:00
ircd::prof: Add callgrind hypercall suite.
This commit is contained in:
parent
def7ee2753
commit
55fc2c6f76
3 changed files with 73 additions and 0 deletions
|
@ -783,6 +783,7 @@ dnl instrumentation
|
|||
RB_CHK_SYSHEADER(malloc.h, [MALLOC_H])
|
||||
RB_CHK_SYSHEADER(valgrind/valgrind.h, [VALGRIND_VALGRIND_H])
|
||||
RB_CHK_SYSHEADER(valgrind/memcheck.h, [VALGRIND_MEMCHECK_H])
|
||||
RB_CHK_SYSHEADER(valgrind/callgrind.h, [VALGRIND_CALLGRIND_H])
|
||||
|
||||
dnl experimental
|
||||
RB_CHK_SYSHEADER(experimental/string_view, [EXPERIMENTAL_STRING_VIEW])
|
||||
|
|
|
@ -60,11 +60,36 @@ namespace ircd::prof::x86
|
|||
unsigned long long rdtsc();
|
||||
}
|
||||
|
||||
/// Callgrind hypercall suite
|
||||
namespace ircd::prof::vg
|
||||
{
|
||||
struct enable;
|
||||
struct disable;
|
||||
|
||||
void dump(const char *const reason = nullptr);
|
||||
void toggle();
|
||||
void reset();
|
||||
void start() noexcept;
|
||||
void stop() noexcept;
|
||||
}
|
||||
|
||||
namespace ircd
|
||||
{
|
||||
using prof::cycles;
|
||||
}
|
||||
|
||||
struct ircd::prof::vg::enable
|
||||
{
|
||||
enable() noexcept { start(); }
|
||||
~enable() noexcept { stop(); }
|
||||
};
|
||||
|
||||
struct ircd::prof::vg::disable
|
||||
{
|
||||
disable() noexcept { stop(); }
|
||||
~disable() noexcept { start(); }
|
||||
};
|
||||
|
||||
struct ircd::prof::times
|
||||
{
|
||||
uint64_t real {0};
|
||||
|
|
47
ircd/prof.cc
47
ircd/prof.cc
|
@ -13,6 +13,7 @@
|
|||
#include <RB_INC_SYS_MMAN_H
|
||||
#include <RB_INC_SYS_RESOURCE_H
|
||||
#include <linux/perf_event.h>
|
||||
#include <RB_INC_VALGRIND_CALLGRIND_H
|
||||
#include <boost/chrono/chrono.hpp>
|
||||
#include <boost/chrono/process_cpu_clocks.hpp>
|
||||
|
||||
|
@ -772,6 +773,52 @@ ircd::prof::time_user()
|
|||
return boost::chrono::process_user_cpu_clock::now().time_since_epoch().count();
|
||||
}
|
||||
|
||||
//
|
||||
// prof::vg
|
||||
//
|
||||
|
||||
void
|
||||
ircd::prof::vg::stop()
|
||||
noexcept
|
||||
{
|
||||
#ifdef HAVE_VALGRIND_CALLGRIND_H
|
||||
CALLGRIND_STOP_INSTRUMENTATION;
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
ircd::prof::vg::start()
|
||||
noexcept
|
||||
{
|
||||
#ifdef HAVE_VALGRIND_CALLGRIND_H
|
||||
CALLGRIND_START_INSTRUMENTATION;
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
ircd::prof::vg::reset()
|
||||
{
|
||||
#ifdef HAVE_VALGRIND_CALLGRIND_H
|
||||
CALLGRIND_ZERO_STATS;
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
ircd::prof::vg::toggle()
|
||||
{
|
||||
#ifdef HAVE_VALGRIND_CALLGRIND_H
|
||||
CALLGRIND_TOGGLE_COLLECT;
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
ircd::prof::vg::dump(const char *const reason)
|
||||
{
|
||||
#ifdef HAVE_VALGRIND_CALLGRIND_H
|
||||
CALLGRIND_DUMP_STATS_AT(reason);
|
||||
#endif
|
||||
}
|
||||
|
||||
//
|
||||
// times
|
||||
//
|
||||
|
|
Loading…
Reference in a new issue