CallLocalFunction VS CallFunction directly
#1

pawn Код:
#include <a_samp>

main() {
    new count1 = GetTickCount();
    for(new i=0;i<10000000;i++) {
        CallLocalFunction("OnPlayerCommandText", "ds", i, "/test");
    }
    printf("[CallLocalFuntion]OnPlayerCommandText:%dms",GetTickCount() - count1);
    new count2 = GetTickCount();
    for(new i=0;i<10000000;i++) {
        CallLocalFunction("OnPlayerKeyStateChange", "dd", i, KEY_SUBMISSION);
    }
    printf("[CallLocalFuntion]OnPlayerKeyStateChange:%dms",GetTickCount() - count2);
    new count3 = GetTickCount();
    for(new i=0;i<10000000;i++) {
        OnPlayerCommandText(i, "/test");
    }
    printf("OnPlayerCommandText:%dms",GetTickCount() - count3);
    new count4 = GetTickCount();
    for(new i=0;i<10000000;i++) {
        OnPlayerKeyStateChange(i, KEY_SUBMISSION, KEY_SUBMISSION);
    }
    printf("OnPlayerKeyStateChange:%dms",GetTickCount() - count4);
}

public OnPlayerCommandText(playerid, cmdtext[]) {
    return 0;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) {
    return 1;
}
Код:
[00:37:09] [CallLocalFuntion]OnPlayerCommandText:2997ms
[00:37:12] [CallLocalFuntion]OnPlayerKeyStateChange:3395ms
[00:37:13] OnPlayerCommandText:395ms
[00:37:13] OnPlayerKeyStateChange:433ms
I use TickCount first time and I got this.
Only want to know why.pls
Reply
#2

The main reason to consider using CallLocalFunction is that it takes a string parameter for the function name, letting the user manipulate function calling in a more dynamic way.
Reply
#3

Quote:
Originally Posted by Anzipane
Посмотреть сообщение
The main reason to consider using CallLocalFunction is that it takes a string parameter for the function name, letting the user manipulate function calling in a more dynamic way.
Thank you.
I got it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)