Announcement

REXYGEN forum has been moved. This one is closed.
Head over to the new REXYGEN Community Forum at https://forum.rexygen.com.

Looking forward to meeting you there!
 

#1 2018-04-06 11:09:14

bodie
Member
Registered: 2016-12-19
Posts: 10

REXLANG measure duration of code execution

Hello,
ïs it possible somehow to measure, how long the code inside REXLANG is running each periode? I tried using functions CurrentTime and ElapsedTime, but this is not working.

Thanks for help.

example:

long main(void)
{	
	time_start = CurrentTime();

        /*EXECUTED CODE*/
	
	time_out = ElapsedTime(CurrentTime(),time1);
	
	return 0;
}

Offline

#2 2018-04-06 11:17:52

tomáš čechura
Administrator
Registered: 2016-02-22
Posts: 371

Re: REXLANG measure duration of code execution

Hello bodie,

your approach is completely right - I would do it the same way.

The issue is that you are referencing wrong variable into ElapsedTime() function. It should look like:

long main(void)
{	
	time_start = CurrentTime();

        /*EXECUTED CODE*/
	
	time_out = ElapsedTime(CurrentTime(),time_start);
	
	return 0;
}

Hope it helps.

Regards, Tomas

Offline

#3 2018-04-06 12:11:43

bodie
Member
Registered: 2016-12-19
Posts: 10

Re: REXLANG measure duration of code execution

Hello,
it is my mistake, I do not change the name of both variables in the post, in the REXLANG code it is OK. Problem is that the time_out is zero. I checked value time_start in Trace (or CurrentTime from each periode, see code below) and it is not changing for several periodes. The periode of task is 2 ms. I do not know what is the resolution of ElapsedTime function?
The data type of time1 variable is double.


long init(void)
{		
	time1 = CurrentTime();
			
	return 0;
}

long main(void)
{	
	Trace(11,CurrentTime()-time1);
	
	return 0;
}

6.4.2018    13:07:41.009    Info    REXLANG[00289,00029,0011]: 7052
6.4.2018    13:07:41.011    Info    REXLANG[00289,00029,0011]: 7052
6.4.2018    13:07:41.013    Info    REXLANG[00289,00029,0011]: 7052
6.4.2018    13:07:41.015    Info    REXLANG[00289,00029,0011]: 7067
6.4.2018    13:07:41.017    Info    REXLANG[00289,00029,0011]: 7067
6.4.2018    13:07:41.019    Info    REXLANG[00289,00029,0011]: 7067
6.4.2018    13:07:41.021    Info    REXLANG[00289,00029,0011]: 7067
6.4.2018    13:07:41.023    Info    REXLANG[00289,00029,0011]: 7067
6.4.2018    13:07:41.025    Info    REXLANG[00289,00029,0011]: 7067
6.4.2018    13:07:41.027    Info    REXLANG[00289,00029,0011]: 7067
6.4.2018    13:07:41.029    Info    REXLANG[00289,00029,0011]: 7083
6.4.2018    13:07:41.031    Info    REXLANG[00289,00029,0011]: 7083
6.4.2018    13:07:41.033    Info    REXLANG[00289,00029,0011]: 7083
6.4.2018    13:07:41.035    Info    REXLANG[00289,00029,0011]: 7083

Offline

#4 2018-04-09 15:49:38

jaroslav_sobota
Administrator
Registered: 2015-10-27
Posts: 535

Re: REXLANG measure duration of code execution

Hi bodie,
are you sure the time1 variable is of type double? I guess it's a long in your declaration.

Let me know,
Jaroslav

Offline

#5 2018-04-10 08:41:17

bodie
Member
Registered: 2016-12-19
Posts: 10

Re: REXLANG measure duration of code execution

Hello,
the declaration looks like this:

double time1 = 0;

I tried using

double time1 = 0.0;

to see if the type is not cast to long, but it did not help.


I tried several things and now it is working - the code is OK, but I was running it on localhost on PC. When I download it to RPi3 and run, it is OK.
So only for be sure, is there problem running some functions on PC, or probably is it some kind of bug?

Offline

#6 2018-04-10 09:40:16

tomáš čechura
Administrator
Registered: 2016-02-22
Posts: 371

Re: REXLANG measure duration of code execution

Hello Bodie,

sorry for troubles with platform inconsistency. You are right - on Linux based systems it works well - however you should be aware that ElapsedTime() returns value in microseconds (Linux) / miliseconds (Windows).

Many thanks for reporting this bug. We will fix it in next release.

If I can be of any assistance, let me know.

Regards, Tomas

Offline

#7 2018-04-10 09:46:28

bodie
Member
Registered: 2016-12-19
Posts: 10

Re: REXLANG measure duration of code execution

Thanks for informations and your help.

Offline

Board footer

Powered by FluxBB