How many ms a function took to proceed
#1

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

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

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);
Reply
#4

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

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.
Reply
#6

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.
Reply
#7

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


Forum Jump:


Users browsing this thread: 1 Guest(s)