mirror of https://github.com/ArduPilot/ardupilot
AP_HAL_Linux: Perf: make lttng use internal fields
Instead of creating a new object Perf_Lttng copying the necessaries fields, just make a tighter integration with the internal perf counters and re-use the same fields.
This commit is contained in:
parent
619ce23799
commit
1727418dc9
|
@ -86,9 +86,7 @@ void Perf::begin(Util::perf_counter_t pc)
|
|||
|
||||
perf.start = now_nsec();
|
||||
|
||||
#ifdef HAVE_LTTNG_UST
|
||||
perf.lttng.begin();
|
||||
#endif
|
||||
perf.lttng.begin(perf.name);
|
||||
}
|
||||
|
||||
void Perf::end(Util::perf_counter_t pc)
|
||||
|
@ -137,9 +135,7 @@ void Perf::end(Util::perf_counter_t pc)
|
|||
perf.m2 += (delta_intvl * (elapsed - perf.mean));
|
||||
perf.start = 0;
|
||||
|
||||
#ifdef HAVE_LTTNG_UST
|
||||
perf.lttng.end();
|
||||
#endif
|
||||
perf.lttng.end(perf.name);
|
||||
}
|
||||
|
||||
void Perf::count(Util::perf_counter_t pc)
|
||||
|
@ -161,10 +157,7 @@ void Perf::count(Util::perf_counter_t pc)
|
|||
_update_count++;
|
||||
perf.count++;
|
||||
|
||||
#ifdef HAVE_LTTNG_UST
|
||||
perf.lttng.count();
|
||||
#endif
|
||||
|
||||
perf.lttng.count(perf.name, perf.count);
|
||||
}
|
||||
|
||||
Util::perf_counter_t Perf::add(Util::perf_counter_type type, const char *name)
|
||||
|
|
|
@ -37,17 +37,12 @@ public:
|
|||
Perf_Counter(perf_counter_type type_, const char *name_)
|
||||
: name{name_}
|
||||
, type{type_}
|
||||
#ifdef HAVE_LTTNG_UST
|
||||
, lttng{name_}
|
||||
#endif
|
||||
, least{ULONG_MAX}
|
||||
{
|
||||
}
|
||||
|
||||
const char *name;
|
||||
#ifdef HAVE_LTTNG_UST
|
||||
Perf_Lttng lttng;
|
||||
#endif
|
||||
|
||||
perf_counter_type type;
|
||||
|
||||
|
|
|
@ -19,32 +19,35 @@
|
|||
|
||||
#include <string.h>
|
||||
|
||||
#include <AP_HAL/AP_HAL.h>
|
||||
|
||||
#include "AP_HAL_Linux.h"
|
||||
#include "Perf_Lttng_TracePoints.h"
|
||||
#include "Perf_Lttng.h"
|
||||
|
||||
using namespace Linux;
|
||||
|
||||
Perf_Lttng::Perf_Lttng(const char *name)
|
||||
void Perf_Lttng::begin(const char *name)
|
||||
{
|
||||
strncpy(_name, name, MAX_TRACEPOINT_NAME_LEN);
|
||||
tracepoint(ardupilot, begin, name);
|
||||
}
|
||||
|
||||
void Perf_Lttng::begin()
|
||||
void Perf_Lttng::end(const char *name)
|
||||
{
|
||||
tracepoint(ardupilot, begin, _name);
|
||||
tracepoint(ardupilot, end, name);
|
||||
}
|
||||
|
||||
void Perf_Lttng::end()
|
||||
void Perf_Lttng::count(const char *name, uint64_t val)
|
||||
{
|
||||
tracepoint(ardupilot, end, _name);
|
||||
tracepoint(ardupilot, count, name, val);
|
||||
}
|
||||
|
||||
void Perf_Lttng::count()
|
||||
{
|
||||
tracepoint(ardupilot, count, _name, ++_count);
|
||||
}
|
||||
#else
|
||||
|
||||
#include "Perf_Lttng.h"
|
||||
|
||||
using namespace Linux;
|
||||
|
||||
void Perf_Lttng::begin(const char *name) { }
|
||||
void Perf_Lttng::end(const char *name) { }
|
||||
void Perf_Lttng::count(const char *name, uint64_t val) { }
|
||||
|
||||
#endif
|
||||
|
|
|
@ -14,23 +14,17 @@
|
|||
*/
|
||||
#pragma once
|
||||
|
||||
#include <AP_HAL/Util.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "AP_HAL_Linux.h"
|
||||
|
||||
#define MAX_TRACEPOINT_NAME_LEN 128
|
||||
|
||||
namespace Linux {
|
||||
|
||||
class Perf_Lttng {
|
||||
public:
|
||||
Perf_Lttng(const char *name);
|
||||
void begin();
|
||||
void end();
|
||||
void count();
|
||||
private:
|
||||
char _name[MAX_TRACEPOINT_NAME_LEN];
|
||||
uint64_t _count;
|
||||
void begin(const char *name);
|
||||
void end(const char *name);
|
||||
void count(const char *name, uint64_t val);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ TRACEPOINT_EVENT(
|
|||
ardupilot,
|
||||
begin,
|
||||
TP_ARGS(
|
||||
char*, name_arg
|
||||
const char*, name_arg
|
||||
),
|
||||
TP_FIELDS(
|
||||
ctf_string(name_field, name_arg)
|
||||
|
@ -39,7 +39,7 @@ TRACEPOINT_EVENT(
|
|||
ardupilot,
|
||||
end,
|
||||
TP_ARGS(
|
||||
char*, name_arg
|
||||
const char*, name_arg
|
||||
),
|
||||
TP_FIELDS(
|
||||
ctf_string(name_field, name_arg)
|
||||
|
@ -50,7 +50,7 @@ TRACEPOINT_EVENT(
|
|||
ardupilot,
|
||||
count,
|
||||
TP_ARGS(
|
||||
char*, name_arg,
|
||||
const char*, name_arg,
|
||||
int, count_arg
|
||||
),
|
||||
TP_FIELDS(
|
||||
|
|
Loading…
Reference in New Issue