예제 #1
0
# Creating BytesIO from immutable object should not immediately
# copy its content.
try:
    import uio
    import micropython
    micropython.mem_total
except (ImportError, AttributeError):
    print("SKIP")
    raise SystemExit


data = b"1234" * 256

before = micropython.mem_total()

buf = uio.BytesIO(data)

after = micropython.mem_total()

print(after - before < len(data))
예제 #2
0
# Creating BytesIO from immutable object should not immediately
# copy its content.
try:
    import uio
    import micropython

    micropython.mem_total
except (ImportError, AttributeError):
    print("SKIP")
    raise SystemExit

data = b"1234" * 256

before = micropython.mem_total()

buf = uio.BytesIO(data)

after = micropython.mem_total()

print(after - before < len(data))
예제 #3
0
# tests meminfo functions in micropython module

import micropython

# these functions are not always available
if not hasattr(micropython, 'mem_total'):
    print('SKIP')
else:
    t = micropython.mem_total()
    c = micropython.mem_current()
    p = micropython.mem_peak()

    l = list(range(10000))

    print(micropython.mem_total() > t)
    print(micropython.mem_current() > c)
    print(micropython.mem_peak() > p)
예제 #4
0
def main():
    print('"%s" % "a"')
    t = micropython.mem_total()
    "%s" % "a"
    mem_modulo = micropython.mem_total() - t
    #print(mem_modulo)

    print('"{}".format("a")')
    t = micropython.mem_total()
    "{}".format("a")
    mem_format = micropython.mem_total() - t
    #print(mem_format)
    print(mem_format <= mem_modulo)

    print('"%d" % 1')
    t = micropython.mem_total()
    "%d" % 1
    mem_modulo = micropython.mem_total() - t
    #print(mem_modulo)

    print('"{}".format(1)')
    t = micropython.mem_total()
    "{}".format(1)
    mem_format_int = micropython.mem_total() - t
    #print(mem_format_int)
    print(mem_format_int <= mem_modulo)

    print('"{:d}".format(1)')
    t = micropython.mem_total()
    "{:d}".format(1)
    mem_format = micropython.mem_total() - t
    #print(mem_format)
    print(mem_format <= mem_modulo)

    print('"%s" % 1')
    t = micropython.mem_total()
    "%s" % 1
    mem_modulo = micropython.mem_total() - t
    #print(mem_modulo)
    print(mem_format_int < mem_modulo)

    # Multiple args should be always more efficient with .format(), as that
    # avoids allocating arg tuple.
    print('"%s %d" % ("a", 1)')
    t = micropython.mem_total()
    "%s %d" % ("a", 1)
    mem_modulo = micropython.mem_total() - t
    #print(mem_modulo)

    print('"{} {}".format("a", 1)')
    t = micropython.mem_total()
    "{} {}".format("a", 1)
    mem_format_2arg = micropython.mem_total() - t
    #print(mem_format_2arg)
    print(mem_format_2arg < mem_modulo)

    # ... But preallocated tuple, should be the same.
    print('"%s %d" % ("a", 1)  #2')
    args = ("a", 1)
    t = micropython.mem_total()
    "%s %d" % args
    mem_modulo = micropython.mem_total() - t
    #print(mem_modulo)
    print(mem_format_2arg == mem_modulo)
예제 #5
0
# tests meminfo functions in micropython module

import micropython

# these functions are not always available
if not hasattr(micropython, "mem_total"):
    print("SKIP")
else:
    t = micropython.mem_total()
    c = micropython.mem_current()
    p = micropython.mem_peak()

    l = list(range(10000))

    print(micropython.mem_total() > t)
    print(micropython.mem_current() > c)
    print(micropython.mem_peak() > p)