-
Mar 15th, 2024, 07:41 AM
#1
Thread Starter
PowerPoster
how optimizate the programming?
i don't choose any programming language, because these question is for all programming languages...
everyone can create their own algorithm, but some can be slow and others can be faster...
ok... if we use Graphics libraries, they can be much faster than CPU functions.... but forgetting these, what is the best steps for we create a much more faster algorithm?
seems a basic question, but i didn't learned about optimization code on school... all most everything that i learned was by me(ebooks and forums)
-
Mar 15th, 2024, 07:53 AM
#2
Re: how optimizate the programming?
To start, by reading about existing algos from books/articles which are language agnostic. From there, depending on what it is you're trying to do, you tinker by implementing one of those algos and then push things around. But also understand that some of these have been around for decades, have already been optimized, and sometimes depending on the number or nature of things, some things will only be faster than others in certain situations. Sort is a classic example of this. There's really only so many ways that it can be done, and it's been something that's been refined over time, and so it's probably as good as it's going to get, and only the hardware can make improvements. That's what's happened with graphics... things are faster than they used to be because for the most part the CPU doesn't really do graphics anymore... it's off-loaded to the GPU, freeing up the CPU for other work. Most modern libraries now take advantage of that, which is why they're faster than they used to be.
That said, also learning about Assembly helped my back in the day (now with speeds that they are, I don't need to worry about squeeziong every possible tick out of a CPU) to right tighter code and "efficient" code in VB. It forced me to think about hte little things, like how I structure my If statements and how I run loops. I still kind of do it, but to a much lesser extent now.
-tg
-
Mar 15th, 2024, 08:06 AM
#3
Re: how optimizate the programming?
The authoritative source re algorithms is Donald Knuth's 'Art of Computer Programming'
https://www.amazon.co.uk/Computer-Pr...102/ref=sr_1_1
All advice is offered in good faith only. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
Mar 15th, 2024, 08:47 AM
#4
Thread Starter
PowerPoster
Re: how optimizate the programming?
i have 1 sub for change the brush\pen.... i must change the brush\pen, but i used an if for test if is the same, of previous, so i can win so much speed
Last edited by joaquim; Mar 15th, 2024 at 08:51 AM.
-
Mar 15th, 2024, 09:11 AM
#5
Re: how optimizate the programming?
 Originally Posted by joaquim
i don't choose any programming language, because these question is for all programming languages...
everyone can create their own algorithm, but some can be slow and others can be faster...
ok... if we use Graphics libraries, they can be much faster than CPU functions.... but forgetting these, what is the best steps for we create a much more faster algorithm?
seems a basic question, but i didn't learned about optimization code on school... all most everything that i learned was by me(ebooks and forums)
Also get familiar with a good benchmarking / performance profiler if you really want to see what different algorithms and performance tweaks actually change. Be aware that modern compilers can often perform a lot of optimisations as well, sometimes trying to write optimised code can defeat the compiler's ability to generate more efficient code.
-
Mar 15th, 2024, 10:45 AM
#6
Thread Starter
PowerPoster
Re: how optimizate the programming?
why the programming books(or general programming books) don't speak about optimization code?
-
Mar 15th, 2024, 11:01 AM
#7
Re: how optimizate the programming?
There are two distinct optimisations - algorithm optimisations which are covered in good/advanced algorithm books and program optimisations which are covered in good/advanced language specific books. Both are important. IMO the main one being algorithm optimisation.
All advice is offered in good faith only. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/
C++23 Compiler: Microsoft VS2022 (17.6.5)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|