from micropython import const
from vts import Chrono, delay_ms as sleep
import gc


t = Chrono()
ITERATIONS = const(10000)
s = set()
l = list()


if __name__ == "__main__":

    t.restart()
    for i in range(ITERATIONS):
        z = i%15
        s.add(z)
        (i in s)
    print('Function \'{}\' took {:6.3f}ms'.format('Set add', t.read()/1000))
    s.clear()
    gc.collect()

    t.restart()
    for i in range(ITERATIONS):
        z = i%15
        if not (z in s):
            s.add(z)
        (i in s)
    print('Function \'{}\' took {:6.3f}ms'.format('Set Check then Add',t.read()/1000))
    s.clear()
    gc.collect()

    t.restart()
    for i in range(ITERATIONS):
        z = i%15
        if not (z in l):
            l.append(z)
        a = (i in l)
    print('Function \'{}\' took Time = {:6.3f}ms'.format('List Add', t.read()/1000))
