timeval calcualtions - timeradd/timersub

permal
Posts: 384
Joined: Sun May 14, 2017 5:36 pm

timeval calcualtions - timeradd/timersub

Postby permal » Tue Aug 01, 2017 8:35 am

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?

BuddyCasino
Posts: 263
Joined: Sun Jun 19, 2016 12:00 am

Re: timeval calcualtions - timeradd/timersub

Postby BuddyCasino » Tue Aug 01, 2017 9:18 am

+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.

permal
Posts: 384
Joined: Sun May 14, 2017 5:36 pm

Re: timeval calcualtions - timeradd/timersub

Postby permal » Tue Aug 01, 2017 10:21 am

@BuddyCasino Care to share your results?

BuddyCasino
Posts: 263
Joined: Sun Jun 19, 2016 12:00 am

Re: timeval calcualtions - timeradd/timersub

Postby BuddyCasino » Tue Aug 01, 2017 12:06 pm

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.

permal
Posts: 384
Joined: Sun May 14, 2017 5:36 pm

Re: timeval calcualtions - timeradd/timersub

Postby permal » Tue Aug 01, 2017 12:37 pm

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.

ESP_igrr
Posts: 2072
Joined: Tue Dec 01, 2015 8:37 am

Re: timeval calcualtions - timeradd/timersub

Postby ESP_igrr » Tue Aug 01, 2017 2:02 pm

If you don't mind, please open a Github issue for this. That would reduce the chances of us forgetting about this request.

permal
Posts: 384
Joined: Sun May 14, 2017 5:36 pm

Re: timeval calcualtions - timeradd/timersub

Postby permal » Tue Aug 01, 2017 2:09 pm


User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: timeval calcualtions - timeradd/timersub

Postby kolban » Tue Aug 01, 2017 4:26 pm

The timeval utilities I use in projects can be found here:

https://github.com/nkolban/duktape-esp3 ... imeutils.c
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

Who is online

Users browsing this forum: Baidu [Spider] and 91 guests