Performance measurement allwo constant tags

This commit is contained in:
Sparchatus 2022-05-31 09:50:43 +00:00
parent f51fbb441e
commit d6526ccbaa
2 changed files with 12 additions and 9 deletions

View File

@ -9,19 +9,19 @@
// #define PERFORMANCE_ENABLED
struct measurement {
char *tag;
const char *tag;
systime_t timestamp;
};
struct performance_context {
size_t count;
char *name;
const char *name;
struct measurement measurements[PERFORMANCE_MEASUREMENT_COUNT_MAX];
};
void perf_init(struct performance_context *c, char *name);
void perf_add_measurement(struct performance_context *c, char *tag, systime_t timestamp);
void perf_add_now(struct performance_context *c, char *tag);
void perf_init(struct performance_context *c, const char *name);
void perf_add_measurement(struct performance_context *c, const char *tag, systime_t timestamp);
void perf_add_now(struct performance_context *c, const char *tag);
void perf_print(struct performance_context *c);
#endif // LIBBARRELFISH_PERFORMANCE_H

View File

@ -3,15 +3,18 @@
#include <aos/systime.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->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);
__asm volatile (
"dmb sy\n"
);
c->measurements[c->count].tag = tag;
c->measurements[c->count].timestamp = timestamp;
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();
perf_add_measurement(c, tag, now);