What's better of these two? -
StrikerZ - 03.10.2017
What's the best option to make timers from these two options.
Multiple Timers
A
PHP Code:
new stime;
forward Time();
public OnGameModeInit()
{
SetTimer("Time",1000,true);
return 1;
}
public Time()
{
// some code
if(stime%120==0) // Do some code each 2 minutes
{
}
if(stime%1800 == 0) // Do some code each 1800 seconds
{
}
stime++;
return 1;
}
Or
B
PHP Code:
public OnGameModeInit()
{
SetTimer("Time",1000,true);
SetTimer("Time1",120000,true);
SetTimer("Time2", 1800000, true);
return 1;
}
forward Time();
forward Time1();
forward Time2();
public Time()
{
}
public Time1()
{
}
public Time2()
{
}
What's best? A or B
Re: What's better of these two? -
DelK - 03.10.2017
I think A, because it's a more optimized option.
Re: What's better of these two? -
OneDay - 03.10.2017
Quote:
Originally Posted by DelK
I think A, because it's a more optimized option.
|
How is more code more optimised than less code? B is better - the server works out who to call not you
Re: What's better of these two? -
whadez - 03.10.2017
(A) Is better. I'm using the same method since I found it out on my own. Oh and also it's easier to find a specific code part in one timer rather than looking up until you find what you were looking for.
Code:
if(++stime%120==0) {
}
if(stime%1800==0) {
}
Re: What's better of these two? -
whadez - 03.10.2017
Quote:
Originally Posted by OneDay
How is more code more optimised than less code? B is better - the server works out who to call not you
|
"How is more code more optimised than less code?"
Less code doesnt mean that it'll run faster. The code amount doesn't matter if you have no clue what you are doing and you use old methods which aren't a thing anymore. Number of lines never matter. Obviously writing a system on the lowest lines of number possible is always a good thing for better readibility, but thats it. Run some tests.
Also having less timers than more timers is a good thing.
Take timers are cron jobs. If you can put code into one cron job instead of making tons of them, why wouldn't you do it?
Re: What's better of these two? -
StrikerZ - 03.10.2017
Quote:
Originally Posted by whadez
"How is more code more optimised than less code?"
Less code doesnt mean that it'll run faster. The code amount doesn't matter if you have no clue what you are doing and you use old methods which aren't a thing anymore. Number of lines never matter. Obviously writing a system on the lowest lines of number possible is always a good thing for better readibility, but thats it. Run some tests.
Also having less timers than more timers is a good thing.
Take timers are cron jobs. If you can put code into one cron job instead of making tons of them, why wouldn't you do it?
|
Well explained!
I'm gonna go with A.
Re: What's better of these two? -
coool - 03.10.2017
Timer's benchmark
https://gist.github.com/Southclaws/7...8e3b67c632483d
Re: What's better of these two? -
KaryM4Life - 21.10.2017
More timers more lag, Less timers less lag A is better.
Re: What's better of these two? -
jlalt - 21.10.2017
Quote:
Originally Posted by KaryM4Life
More timers more lag, Less timers less lag A is better.
|
by what logic is this being said xd?
how they cause lag?
Re: What's better of these two? -
KaryM4Life - 22.10.2017
Quote:
Originally Posted by jlalt
by what logic is this being said xd?
how they cause lag?
|
Another scripter told me that :c