I went through some posts here but could not find them helpful
I used esptool for importing micropython into my wemos D1 mini
However, I'm trying to find a way to calculate code execution time using in-built function 'timeit',
but it's not there
Anybody found a solution for this
Thanks
timeit function not available in machine module
Re: timeit function not available in machine module
To save space, MicroPython doesn't include the whole of the Python standard library.
However you can install some things (including timeit) manually from micropython-lib -- e.g. https://github.com/micropython/micropyt ... ter/timeit
However you can install some things (including timeit) manually from micropython-lib -- e.g. https://github.com/micropython/micropyt ... ter/timeit
Re: timeit function not available in machine module
That timeit function in the micropython-lib looks like overkill, and certainly not made for esp8266.
In that situation, I usually time a function using utime.ticks_us() and utime.ticks_diff().
Edit: I faintly remember that Dave @dhylands had written something more reusable, but than might have been for the old PyBoard API.
In that situation, I usually time a function using utime.ticks_us() and utime.ticks_diff().
Edit: I faintly remember that Dave @dhylands had written something more reusable, but than might have been for the old PyBoard API.
Re: timeit function not available in machine module
Ok I will test itRoberthh wrote: ↑Thu Nov 07, 2019 9:02 pmThat timeit function in the micropython-lib looks like overkill, and certainly not made for esp8266.
In that situation, I usually time a function using utime.ticks_us() and utime.ticks_diff().
Edit: I faintly remember that Dave @dhylands had written something more reusable, but than might have been for the old PyBoard API.
Re: timeit function not available in machine module
Thanksjimmo wrote: ↑Thu Nov 07, 2019 8:47 pmTo save space, MicroPython doesn't include the whole of the Python standard library.
However you can install some things (including timeit) manually from micropython-lib -- e.g. https://github.com/micropython/micropyt ... ter/timeit
I will check
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: timeit function not available in machine module
You'll find a way to time a function call using a decorator here e.g.
Code: Select all
@timed_function
def test():
utime.sleep_us(10000)
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: timeit function not available in machine module
Okpythoncoder wrote: ↑Sat Nov 09, 2019 9:16 amYou'll find a way to time a function call using a decorator here e.g.Code: Select all
@timed_function def test(): utime.sleep_us(10000)
I'll test
Thanks
In case of any doubt I'll get back to you