[Tutorial] New Code Optimizations
#12

Quote:
Originally Posted by Macluawn
View Post
Most of these optimizations are too minute to make a big a noticeable impact. Removing 2 machine code instructions just isnt worth it. If one cares about performance - pawn isnt the language of choice.


It entirely depends on the natives implementation and your use case. Say you wanted to find a substring, you would probably use strfind. The native uses a linear algorithm, but it can be done much faster with, say, kmp with the cost of a little more pre-calculation.
Whatever algorithm you use, natives will always be much faster. The reason is "AMX" is an abstract machine. Some instructions are executed for decoding the P-Code and identifying the arguments,.... Check the source!

Just ****** Abstract Machine, read about it and you'll realize why abstract machines are very slow. The virtual machine has lot of work to do for PAWN Code. PAWN Code is executed by the virtual machine whereas native functions directly run on your real computer.

Just to give you an idea how fast natives can be, here is a custom strcpy functions vs strcat.

http://pastebin.com/Y7RJ21tw

Results:
native: 697,700,718,705
non-native:5484,5422,5507,5562

Mind blown?

Quote:
Originally Posted by Macluawn
View Post
Most of these optimizations are too minute to make a big a noticeable impact. Removing 2 machine code instructions just isnt worth it. If one cares about performance - pawn isnt the language of choice.
Hmm, there are only two examples which do that.And at the beginning of the thread I had mentioned that ignore minor optimizations if you want to and keep the code more readable.

I think "Most of these optimizations are too minute" needs to be changed to "Few of these optimizations are too minute".
Reply


Messages In This Thread
New Code Optimizations - by Yashas - 04.07.2015, 04:01
Re: New Code Optimizations - by Gammix - 04.07.2015, 09:59
Re: New Code Optimizations - by maximthepain - 04.07.2015, 10:33
Re: New Code Optimizations - by theYiin - 04.07.2015, 10:36
Re: New Code Optimizations - by Cypress - 04.07.2015, 10:42
Re: New Code Optimizations - by sammp - 04.07.2015, 10:51
Re: New Code Optimizations - by sammp - 04.07.2015, 10:59
Re: New Code Optimizations - by Gammix - 04.07.2015, 11:53
Re: New Code Optimizations - by Yashas - 04.07.2015, 15:49
Re: New Code Optimizations - by PT - 04.07.2015, 16:04
Re: New Code Optimizations - by Macluawn - 04.07.2015, 16:09
Re: New Code Optimizations - by Yashas - 04.07.2015, 16:17
Re: New Code Optimizations - by Gammix - 04.07.2015, 16:40
Re: New Code Optimizations - by Macluawn - 04.07.2015, 16:41
Re: New Code Optimizations - by Yashas - 04.07.2015, 16:53
Re: New Code Optimizations - by Macluawn - 04.07.2015, 16:56
Re: New Code Optimizations - by Yashas - 04.07.2015, 16:59
Re: New Code Optimizations - by Lynn - 04.07.2015, 17:17
Re: New Code Optimizations - by rymax99 - 04.07.2015, 17:52
Re: New Code Optimizations - by Gammix - 05.07.2015, 02:31
Re: New Code Optimizations - by Tamer - 05.07.2015, 19:50
Re: New Code Optimizations - by Stanford - 06.07.2015, 03:07
Re: New Code Optimizations - by Cypress - 06.07.2015, 20:31
Re: New Code Optimizations - by Yashas - 07.07.2015, 01:57
Re: New Code Optimizations - by Sime30 - 07.07.2015, 17:58
Re: New Code Optimizations - by kristo - 07.07.2015, 18:09
Re: New Code Optimizations - by Sime30 - 07.07.2015, 18:59
Re: New Code Optimizations - by JokeyL - 25.01.2016, 16:38
Re: New Code Optimizations - by iKarim - 25.01.2016, 16:45
Re: New Code Optimizations - by vannesenn - 16.06.2016, 23:38
Re: New Code Optimizations - by Crystallize - 16.06.2016, 23:43
Re: New Code Optimizations - by Gammix - 16.06.2016, 23:43
Re: New Code Optimizations - by Vince - 17.06.2016, 09:37
Re: New Code Optimizations - by Gammix - 17.06.2016, 10:02
Re: New Code Optimizations - by vannesenn - 17.06.2016, 14:38
Re: New Code Optimizations - by vannesenn - 17.06.2016, 21:23
Re: New Code Optimizations - by Yashas - 20.06.2016, 17:22
Re: New Code Optimizations - by Yashas - 21.07.2016, 13:23
Re: New Code Optimizations - by Kaperstone - 15.01.2018, 21:21
Re: New Code Optimizations - by Yashas - 31.01.2018, 17:42

Forum Jump:


Users browsing this thread: 1 Guest(s)