Hello,
in some situations I meet while programming I am wondering about effectiveness of algorithms/functions I use. For example I dont know if it would be better to create a global variable or pass that variable between functions as argument and then return it. I dont know if it is better to make one more mathematic operation or create additional condition for while loop. Are there some programs to test it? I mean if I write both versions can I compare them somehow? Maybe there is a website with many examples or my Visual Studio can do this but im not aware of that? I will be very thankful for your help ;)
By 'effectiveness', I'm assuming you mean efficiency? Well, very often, efficiency isn't necessarily the deciding factor for your programs - ease of use and maintainability are quite often just as, if not more, important. For this reason, you should avoid global variables (unless passing arguments around gets silly, but even then you can use classes).
As for measuring the time taken for your programs, there is an easy way of checking - simply add a timer to the start of your main and check it at the end, so as to work out how long you took. This is a fairly good indicator of efficiency. If you want more detail, then you should profile your code.
Sorry for 'effectiveness'. I meant efficiency. For some time Im writing a game and I dont really care about efficiency. Im doing it mostly for improving my skills so Im trying to use a variety of things. You know I have one class, one struct, one vector, text saving/reading etc so I can learn a bit of everything. But today I decided to participate in programming competition and it is all about time required for program to accomplish the task thats why I became so curious about those things ;)
From a professional standpoint, I will echo what NT3 said about maintainability being very important. If someone writes a program for me that is unreadable because of all the "optimizations" the programmer did, that program is going to be worthless to me because I can't assign another programmer to work on it. Hardware is cheap and optimizing compilers really make trying to optimize at the source code level a waste of time. For commercial applications, most of the time is spent waiting for file or database I/O, it's not spent in the program even for programs processing thousands of transactions per second.
That said, programming competitions are generally more about understanding the math and the algorithm behind the problem, than trying to shave instructions from the execution of the program. For many competition type problems, anybody can write a "brute force" approach, but they will generally not finish in time because of lack of understanding of the math behind the problem.
And this is understanding that I need. I mean I think Im good at math, but Im aware that I know a little about programming. So it is hard for me to choose between some possibilities I see. I dont know the "theory of bytes" I dont know how many of them specific function/variable needs. Where I can learn about it?