04.05.2016, 08:22
Tiny But Super Optimizations
04.05.2016, 08:29
Quote:
Quote:
|
04.05.2016, 08:33
What is more optimised??
this
or
this
Quote:
CMD:lsa(playerid) return SendClientMessage(playerid,-1,"BLAHAAAAA"); |
Quote:
CMD:lsa { SendClientMessage(playerid,-1,"BLAHAAAAA"); return 1; } |
04.05.2016, 08:34
04.05.2016, 09:10
04.05.2016, 09:22
Quote:
PHP Code:
Most people do this when clearing all data in a player's account when a player disconnects or connects (to be sure the new player won't get data from the previous player): PHP Code:
PHP Code:
Just reset them all at once. I have no idea if it's faster and if it is, how much faster. I never tested the speed of it, but it surely is less code and less risk to clear all your vars. |
pawn Code:
public OnPlayerDisconnect(playerid, reason)
{
for(new i = 0; i < sizeof(Players[]); i++) {
Players[playerid][pInfo:i] = 0; // or whatever ur player array is
}
return 1;
}
But for this thread this is completely unnecessary just for the minimal performance difference, it's not worth changing or doing in your current or future game modes. Eh I could see someone using it if they just found out about this way, and want to use it for the nano second differences, but not changes to already made GM's unless their that hungry for the performance.
04.05.2016, 10:23
Quote:
This is a proper way of doing it
pawn Code:
But for this thread this is completely unnecessary just for the minimal performance difference, it's not worth changing or doing in your current or future game modes. Eh I could see someone using it if they just found out about this way, and want to use it for the nano second differences, but not changes to already made GM's unless their that hungry for the performance. |
What people not seem to understand is this topic first assumes(or should) you have a heavily repetitive code, I.E a loop in OPU (Which honestly you shouldn't, but for the sake of example ...) then, having just 100 nanosec saved is alot for a code that loops MAX_SOMETHING 40 times a second.
And also even tho speed might not matter, some of these tiny optimizations are better coding habits, for example I won't sacrifice readability for nano speeds speeds like this:
PHP Code:
for(new i=MAX_SOMETHING;--i!=-1;) //this was bit faster than normal one as I remember
PHP Code:
new HouseI[MAX_HOUSES][HouseInfo],
Iterator: Houses<MAX_HOUSES>,
Housebla[MAX_HOUSES],
Houseblabla[MAX_HOUSES],
Houseblablabla[MAX_HOUSES];
26.08.2016, 09:30
Very nice, I've learned some really useful information
27.10.2016, 00:25
Quote:
^ this. For reference, this is the fastest way I found of checking if a number falls in a range:
pawn Код:
pawn Код:
There are five steps to optimising your code:
|
I don't really think anyone is really using this as reference to update their codes and optimize it, it just serves as a documentation so if someone wants to write new blocks of code he might take a look at and use some of these mentioned to write better code, some of them are interesting and significant in huge projects, some are obviously unnecessary and ugly.
But still this coupled with a good tutorial on good algorithms would make those released gamemodes hell lot more useful.
29.10.2016, 06:05
Quote:
Your English is most perfect of all, I'm pretty sure "most slower" means faster in this case people.
And also please if you provide an optimization provide an speed comparison. |
That's a curious data thanks for it!
29.10.2016, 17:57
Yeah? Well you should. He was trying to help you. PrO.GameR is right, the way you have that worded makes what you are saying really confusing, especially without results. Even I still don't know which one you are trying to say is faster.
31.10.2016, 03:02
People like you make the scripting world a better place for newbies.
15.11.2016, 13:04
I actually found this first post very interesting. I learned something about how the compiler works.
24.11.2016, 20:16
i++ is slower than ++i :P
25.11.2016, 03:07
25.11.2016, 04:24
That is not possible.
i++ and ++i use the same instruction. The only difference is the position of the instruction. There shouldn't be any difference in speed.
i++ and ++i use the same instruction. The only difference is the position of the instruction. There shouldn't be any difference in speed.
« Next Oldest | Next Newest »
Users browsing this thread: 4 Guest(s)