hoshi-lang dev
Yet another programming language
Loading...
Searching...
No Matches
hperf.h
Go to the documentation of this file.
1//
2// Created by XIaokang00010 on 2026/1/1.
3//
4
5#ifndef HOSHI_LANG_HPERF_H
6#define HOSHI_LANG_HPERF_H
7
8#include <cstddef>
9#include <cstdint>
10#include <cstdlib>
11#include <runtime/fs/fs.h>
12#include <runtime/time/time.h>
14
21
23 uint64_t sec;
24 uint64_t nsec;
25};
26
27struct HPerfEvent {
30 void *data[2]; // whatever it is for the event type, just a symbol for the rest of the data
31};
32
34 const char *func_name;
35};
36
38 const char *func_name;
39};
40
42 void *ptr;
43 size_t size;
44};
45
47 void *ptr;
48};
49
55
59 size_t unique_id; // identify each thread, in case multiple threads are running
62 size_t num_events;
63};
64
66
67extern bool hperf_enabled;
68
69extern char hperf_report_filename[2048];
70
71HPerfContext *hperf_context_create(size_t unique_id);
72
74
75HPerfContext *hperf_context_get(size_t unique_id);
76
78
79void hperf_report_func_enter(const char *func_name);
80
81void hperf_report_func_leave(const char *func_name);
82
83void hperf_report_mem_alloc(void *ptr, size_t size);
84
85void hperf_report_mem_free(void *ptr);
86
87void hperf_write_report(const char *filename);
88
89void hperf_init(const char *filename);
90
91#endif // HOSHI_LANG_HPERF_H
HPerfContext * hperf_context_create(size_t unique_id)
Definition hperf.cpp:16
HPerfContext * hperf_context_get(size_t unique_id)
Definition hperf.cpp:191
void hperf_context_finalize(HPerfContext *ctx)
Definition hperf.cpp:32
char hperf_report_filename[2048]
Definition hperf.cpp:14
void hperf_report_func_leave(const char *func_name)
Definition hperf.cpp:84
HPerfContext * hperf_contexts
Definition hperf.cpp:10
bool hperf_enabled
Definition hperf.cpp:12
void hperf_report_mem_free(void *ptr)
Definition hperf.cpp:107
void hperf_write_report(const char *filename)
Definition hperf.cpp:118
HPerfEventType
Definition hperf.h:15
HPerfEvent * hperf_context_add_event(HPerfContext *ctx)
Definition hperf.cpp:52
void hperf_init(const char *filename)
Definition hperf.cpp:202
void hperf_report_mem_alloc(void *ptr, size_t size)
Definition hperf.cpp:95
void hperf_report_func_enter(const char *func_name)
Definition hperf.cpp:73
HPerfContext * prev
Definition hperf.h:57
HPerfPage * current_page
Definition hperf.h:61
HPerfContext * next
Definition hperf.h:58
size_t unique_id
Definition hperf.h:59
size_t num_events
Definition hperf.h:62
HPerfPage * pages
Definition hperf.h:60
const char * func_name
Definition hperf.h:34
const char * func_name
Definition hperf.h:38
HPerfTimestamp timestamp
Definition hperf.h:29
void * data[2]
Definition hperf.h:30
HPerfEventType type
Definition hperf.h:28
HPerfPage * next
Definition hperf.h:53
HPerfEvent data[1024]
Definition hperf.h:51
size_t num_events
Definition hperf.h:52
uint64_t nsec
Definition hperf.h:24
uint64_t sec
Definition hperf.h:23