-
Notifications
You must be signed in to change notification settings - Fork 502
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Profiler: Add MicroPython module for accessing probe data.
- Loading branch information
Showing
4 changed files
with
108 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#include "profiler.h" | ||
|
||
STATIC MP_DEFINE_CONST_FUN_OBJ_0(profiler_get_probes_obj, profiler_get_probes); | ||
STATIC MP_DEFINE_CONST_FUN_OBJ_0(profiler_reset_obj, profiler_reset); | ||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(profiler_get_probe_obj, profiler_get_probe); | ||
|
||
STATIC const mp_map_elem_t profiler_globals_table[] = { | ||
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_profiler) }, | ||
{ MP_ROM_QSTR(MP_QSTR_get_probes), MP_ROM_PTR(&profiler_get_probes_obj) }, | ||
{ MP_ROM_QSTR(MP_QSTR_get_probe), MP_ROM_PTR(&profiler_get_probe_obj) }, | ||
{ MP_ROM_QSTR(MP_QSTR_reset), MP_ROM_PTR(&profiler_reset_obj) }, | ||
}; | ||
STATIC MP_DEFINE_CONST_DICT(mp_module_profiler_globals, profiler_globals_table); | ||
|
||
const mp_obj_module_t profiler_user_cmodule = { | ||
.base = { &mp_type_module }, | ||
.globals = (mp_obj_dict_t*)&mp_module_profiler_globals, | ||
}; | ||
|
||
#if MICROPY_VERSION <= 70144 | ||
MP_REGISTER_MODULE(MP_QSTR_profiler, profiler_user_cmodule, MODULE_PROFILER_ENABLED); | ||
#else | ||
MP_REGISTER_MODULE(MP_QSTR_profiler, profiler_user_cmodule); | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#include "py/runtime.h" | ||
#include "py/objstr.h" | ||
|
||
extern mp_obj_t profiler_get_probes(); | ||
extern mp_obj_t profiler_get_probe(mp_obj_t name); | ||
extern mp_obj_t profiler_reset(); |