summaryrefslogtreecommitdiffstatshomepage
path: root/unix/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'unix/main.c')
-rw-r--r--unix/main.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/unix/main.c b/unix/main.c
index 212bbe877e..cd45e3be86 100644
--- a/unix/main.c
+++ b/unix/main.c
@@ -24,6 +24,7 @@
extern const mp_obj_fun_native_t mp_builtin_open_obj;
void file_init();
void rawsocket_init();
+void ffi_init();
static void execute_from_lexer(mp_lexer_t *lex, mp_parse_input_kind_t input_kind, bool is_repl) {
if (lex == NULL) {
@@ -215,6 +216,18 @@ int usage(void) {
return 1;
}
+mp_obj_t mem_info(void) {
+ printf("mem: total=%d, current=%d, peak=%d\n", m_get_total_bytes_allocated(), m_get_current_bytes_allocated(), m_get_peak_bytes_allocated());
+ return mp_const_none;
+}
+
+mp_obj_t qstr_info(void) {
+ uint n_pool, n_qstr, n_str_data_bytes, n_total_bytes;
+ qstr_pool_info(&n_pool, &n_qstr, &n_str_data_bytes, &n_total_bytes);
+ printf("qstr pool: n_pool=%u, n_qstr=%u, n_str_data_bytes=%u, n_total_bytes=%u\n", n_pool, n_qstr, n_str_data_bytes, n_total_bytes);
+ return mp_const_none;
+}
+
int main(int argc, char **argv) {
qstr_init();
rt_init();
@@ -224,9 +237,12 @@ int main(int argc, char **argv) {
rt_store_attr(m_sys, MP_QSTR_argv, py_argv);
rt_store_name(qstr_from_str("test"), test_obj_new(42));
+ rt_store_name(qstr_from_str("mem_info"), rt_make_function_n(0, mem_info));
+ rt_store_name(qstr_from_str("qstr_info"), rt_make_function_n(0, qstr_info));
file_init();
rawsocket_init();
+ ffi_init();
// Here is some example code to create a class and instance of that class.
// First is the Python, then the C code.