41 #include "sys/sprofiling.h"
43 #ifdef SPROFILES_CONF_MAX
44 #define MAX_PROFILES SPROFILES_CONF_MAX
46 #define MAX_PROFILES 1
49 static struct sprofile_t stat_profile;
50 static struct sprofile_site_t stat_site[MAX_PROFILES];
52 void sprofiling_report(
const char* name, uint8_t pretty)
57 if (!name || strchr(name,
':') || strchr(name,
'\r') || strchr(name,
'\n')) {
58 printf(
"The profile report name is invalid\n");
63 printf(
"\nSPROF: \"%s\" %u sites %u max_sites %lu samples\npc:calls\n", name, stat_profile.num_sites, stat_profile.max_sites, stat_profile.num_samples);
65 printf(
"\nSPROF:%s:%u:%u:%lu\n", name, stat_profile.num_sites, stat_profile.max_sites, stat_profile.num_samples);
67 for(i=0; i<stat_profile.num_sites;i++) {
68 printf(
"%p:%u\n", stat_profile.sites[i].addr, stat_profile.sites[i].calls);
72 struct sprofile_t *sprofiling_get()
77 inline void sprofiling_add_sample(
void *pc)
80 for (i=0;i<stat_profile.num_sites;i++) {
81 if (stat_profile.sites[i].addr == pc)
84 if (i<stat_profile.max_sites) {
85 if (i==stat_profile.num_sites) {
86 stat_profile.sites[i].addr = pc;
87 stat_profile.sites[i].calls = 1;
88 stat_profile.num_sites++;
90 stat_profile.sites[i].calls++;
92 stat_profile.num_samples++;
96 void sprofiling_init(
void)
98 stat_profile.sites = stat_site;
99 stat_profile.max_sites = MAX_PROFILES;
101 sprofiling_arch_init();
104 inline void sprofiling_start(
void)
106 sprofiling_arch_start();
109 inline void sprofiling_stop(
void)
111 sprofiling_arch_stop();