metrics.h (704B)
1 #ifndef KIT_METRICS_H 2 #define KIT_METRICS_H 3 4 #include "core/core.h" 5 6 static inline const KitMetrics* metrics_sink(Compiler* c) { 7 return (c && c->ctx) ? c->ctx->metrics : NULL; 8 } 9 10 static inline void metrics_scope_begin(Compiler* c, const char* name) { 11 const KitMetrics* m = metrics_sink(c); 12 if (m && m->scope_begin) m->scope_begin(m->user, name); 13 } 14 15 static inline void metrics_scope_end(Compiler* c, const char* name) { 16 const KitMetrics* m = metrics_sink(c); 17 if (m && m->scope_end) m->scope_end(m->user, name); 18 } 19 20 static inline void metrics_count(Compiler* c, const char* name, u64 value) { 21 const KitMetrics* m = metrics_sink(c); 22 if (m && m->count) m->count(m->user, name, value); 23 } 24 25 #endif