Page 1 of 1

timeval calcualtions - timeradd/timersub

Posted: Tue Aug 01, 2017 8:35 am
by permal
Hi,

In various posts on this forum we're recommended to use

Code: Select all

gettimeofday()
to get time stamps, but we're missing the convenience macros timeradd & timersub which are located in source file xtensa-esp32-elf/include/sys/time.h. Unfortunately, the entire file is #ifdef'd with

Code: Select all

#if defined (__rtems__) || defined (__CYGWIN__)
so these macros are not available to use when developing for the ESP32.

Are there any plans on making them available for ESP32 development so that we don't have to provide our own copy of them?

Re: timeval calcualtions - timeradd/timersub

Posted: Tue Aug 01, 2017 9:18 am
by BuddyCasino
+1 for an easy timer API - I researched quite some time which of the various time APIs are the best fit to measure execution time of functions in millis/nanos.

Re: timeval calcualtions - timeradd/timersub

Posted: Tue Aug 01, 2017 10:21 am
by permal
@BuddyCasino Care to share your results?

Re: timeval calcualtions - timeradd/timersub

Posted: Tue Aug 01, 2017 12:06 pm
by BuddyCasino
Look at timersub / timeradd in https://github.com/nkolban/esp32-snippe ... QTTLinux.c.
Its basically gettimeofday() with some macros. Not sure thats the best way.

Re: timeval calcualtions - timeradd/timersub

Posted: Tue Aug 01, 2017 12:37 pm
by permal
Those looks like an exact copy of the macros in the file I referenced in my original post.

Lets hope Espressif can give us a positive answer to my initial question.

Re: timeval calcualtions - timeradd/timersub

Posted: Tue Aug 01, 2017 2:02 pm
by ESP_igrr
If you don't mind, please open a Github issue for this. That would reduce the chances of us forgetting about this request.

Re: timeval calcualtions - timeradd/timersub

Posted: Tue Aug 01, 2017 2:09 pm
by permal

Re: timeval calcualtions - timeradd/timersub

Posted: Tue Aug 01, 2017 4:26 pm
by kolban
The timeval utilities I use in projects can be found here:

https://github.com/nkolban/duktape-esp3 ... imeutils.c