builtinmp.c 801 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <assert.h>

#include "misc.h"
#include "mpconfig.h"
#include "obj.h"
#include "builtin.h"

// Various builtins specific to MicroPython runtime,
// living in micropython module

#if MICROPY_MEM_STATS
static mp_obj_t mem_total() {
    return MP_OBJ_NEW_SMALL_INT(m_get_total_bytes_allocated());
}

static mp_obj_t mem_current() {
    return MP_OBJ_NEW_SMALL_INT(m_get_current_bytes_allocated());
}

static mp_obj_t mem_peak() {
    return MP_OBJ_NEW_SMALL_INT(m_get_peak_bytes_allocated());
}

MP_DEFINE_CONST_FUN_OBJ_0(mp_builtin_mem_total_obj, mem_total);
MP_DEFINE_CONST_FUN_OBJ_0(mp_builtin_mem_current_obj, mem_current);
MP_DEFINE_CONST_FUN_OBJ_0(mp_builtin_mem_peak_obj, mem_peak);
#endif