SA-MP Forums Archive
Which one is faster? - 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: Which one is faster? (/showthread.php?tid=637771)



Which one is faster? - DuyDang2412 - 21.07.2017

Hi guys, I have two ways to use timer:
1. ptask
PHP код:
ptask UpdateTime[10000](playerid)
{
    new 
time0time1time2;
    
gettime(time0time1time2);
    
SetPlayerTime(playeridtime0time1);
    return 
1;

2. task with foreach loop
PHP код:
task UpdateTime[10000]()
{
    foreach(new 
iPlayer)
    {
        new 
time0time1time2;
        
gettime(time0time1time2);
        
SetPlayerTime(playeridtime0time1);
    }
    return 
1;

I wanna know which one is faster to use, please help me. Thank you!


Re: Which one is faster? - GuilhermeNunes - 21.07.2017

Foreach


Re: Which one is faster? - Kaperstone - 21.07.2017

ptask is certainly prettier.


I am sure there is not such a big performance difference between the two, otherwise ****** would have noted that it ptask is slower, but prettier.


Re: Which one is faster? - DuyDang2412 - 21.07.2017

Thanks guys. But when I use the ptask way, it gives me error:
Quote:

array sizes do not match, or destination array is too small

at this line:
Quote:

ptask UpdateTime[10000](playerid)

Can someone help me with this? Thank you.