Performance measurement allwo constant tags
This commit is contained in:
parent
f51fbb441e
commit
d6526ccbaa
@ -9,19 +9,19 @@
|
|||||||
// #define PERFORMANCE_ENABLED
|
// #define PERFORMANCE_ENABLED
|
||||||
|
|
||||||
struct measurement {
|
struct measurement {
|
||||||
char *tag;
|
const char *tag;
|
||||||
systime_t timestamp;
|
systime_t timestamp;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct performance_context {
|
struct performance_context {
|
||||||
size_t count;
|
size_t count;
|
||||||
char *name;
|
const char *name;
|
||||||
struct measurement measurements[PERFORMANCE_MEASUREMENT_COUNT_MAX];
|
struct measurement measurements[PERFORMANCE_MEASUREMENT_COUNT_MAX];
|
||||||
};
|
};
|
||||||
|
|
||||||
void perf_init(struct performance_context *c, char *name);
|
void perf_init(struct performance_context *c, const char *name);
|
||||||
void perf_add_measurement(struct performance_context *c, char *tag, systime_t timestamp);
|
void perf_add_measurement(struct performance_context *c, const char *tag, systime_t timestamp);
|
||||||
void perf_add_now(struct performance_context *c, char *tag);
|
void perf_add_now(struct performance_context *c, const char *tag);
|
||||||
void perf_print(struct performance_context *c);
|
void perf_print(struct performance_context *c);
|
||||||
|
|
||||||
#endif // LIBBARRELFISH_PERFORMANCE_H
|
#endif // LIBBARRELFISH_PERFORMANCE_H
|
||||||
|
|||||||
@ -3,15 +3,18 @@
|
|||||||
#include <aos/systime.h>
|
#include <aos/systime.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
void perf_init(struct performance_context *c, char *name) {
|
void perf_init(struct performance_context *c, const char *name) {
|
||||||
c->count = 0;
|
c->count = 0;
|
||||||
c->name = name;
|
c->name = name;
|
||||||
memset(c->measurements, 0, sizeof(c->measurements));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void perf_add_measurement(struct performance_context *c, char *tag, systime_t timestamp)
|
inline void perf_add_measurement(struct performance_context *c, const char *tag, systime_t timestamp)
|
||||||
{
|
{
|
||||||
assert(c->count < PERFORMANCE_MEASUREMENT_COUNT_MAX);
|
assert(c->count < PERFORMANCE_MEASUREMENT_COUNT_MAX);
|
||||||
|
|
||||||
|
__asm volatile (
|
||||||
|
"dmb sy\n"
|
||||||
|
);
|
||||||
c->measurements[c->count].tag = tag;
|
c->measurements[c->count].tag = tag;
|
||||||
c->measurements[c->count].timestamp = timestamp;
|
c->measurements[c->count].timestamp = timestamp;
|
||||||
c->count++;
|
c->count++;
|
||||||
@ -20,7 +23,7 @@ inline void perf_add_measurement(struct performance_context *c, char *tag, systi
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void perf_add_now(struct performance_context *c, char *tag)
|
inline void perf_add_now(struct performance_context *c, const char *tag)
|
||||||
{
|
{
|
||||||
systime_t now = systime_now();
|
systime_t now = systime_now();
|
||||||
perf_add_measurement(c, tag, now);
|
perf_add_measurement(c, tag, now);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user