SA-MP Forums Archive
How many ms a function took to proceed - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: How many ms a function took to proceed (/showthread.php?tid=379106)



How many ms a function took to proceed - Emre__ - 20.09.2012

How can I get use a function microtime like in PHP? Is there any func related or exact same of that?


Re: How many ms a function took to proceed - Kyle - 20.09.2012

Код:
stock Function()
{
    new time = gettime();
    // code between the two gettime functions.
    new time2 = gettime();
    printf("Time function took to execute: %d ms", time2-time);
}



Re: How many ms a function took to proceed - jameskmonger - 20.09.2012

Wrong. That will get the time between the start and end of the function.

pawn Код:
new time = gettime();
function();
new time2 = gettime();
printf("%s took %d ms.", "function()", time2-time);



AW: How many ms a function took to proceed - BigETI - 21.09.2012

Instead of
pawn Код:
gettime(&hour = 0, &minute = 0, &second = 0)
you can use
pawn Код:
GetTickCount()



Re: AW: How many ms a function took to proceed - Kyle - 21.09.2012

Quote:
Originally Posted by BigETI
Посмотреть сообщение
Instead of
pawn Код:
gettime(&hour = 0, &minute = 0, &second = 0)
you can use
pawn Код:
GetTickCount()
<@cessil> if you don't use parameters it returns the total seconds.

Though gettickcount would be more accurate.


Re: How many ms a function took to proceed - Kyle - 21.09.2012

Quote:
Originally Posted by jameskmonger
Посмотреть сообщение
Wrong. That will get the time between the start and end of the function.

pawn Код:
new time = gettime();
function();
new time2 = gettime();
printf("%s took %d ms.", "function()", time2-time);
You are incorrect, he doesn't specify what he needs it or uses it for. Therefore, I was correct initially.


AW: How many ms a function took to proceed - BigETI - 21.09.2012

I've been using GetTickCount to get milliseconds
https://sampwiki.blast.hk/wiki/GetTickCount