How do I count the exact number of executed commands for a MIPS program? I want to know what the best way is to count the number of executed commands for a given MIPS program. Let's say we're given a simple for loop that counts from $0$ to $100$. For this I would write the following MIPS code:

li $s1, 0      
li $t0, 100                    

for_loop: 
    addi $s1, $s1, 1            
    beq $s1, $t0, exit      
    j for_loop              

exit:


Since I have $2$ li's before the loop, that would be $+2$ commands and then within the for_loop, the 99 loops pass for addi, beq and j which makes it $99⋅3$ and then $2$ for addi and beq. That makes it a total of $301$ executed commands. Is my answer correct? If not then what is the correct procedure to count the number of executed commands and if in the future I come across a more complex example, then how should I deal with it?
There are two ways: You use a simulator and count the actual number of instructions (or do it manually), which of course only works for fixed input like your case here. Or you use mathematics to calculate the number of instructions, just as you did. 

In general, mathematical analysis ranges from easy to hard to impossible for humans, so there is no general method. 

Sometimes you’re lucky to get a result like “about 2.25 n^2”, or “$\Theta (n^2)$ or similar. How do you deal with it? You do your best.