470,590 Members | 1,789 Online

# How do I calculate the absolute speed of this algorithm below? 74 64KB
If the time it takes to execute a memory access is 100 nanoseconds and that all other operations (arithmetic, register accesses, etc.) take 10 nanoseconds, and what if I have this formula, do you think it would be possible to calculate it then? I am pretty sure this problem can be used to calculate the absolute speed. I know that we do have one of variables already which is Ta= 100 nanoseconds, right? The rest of the missing variables could be found through the lines of code I have provided? Here the formula for the absolute speed :
T= Tna × Nna + Ta × Na

T= Absolute speed of the algorithm

Tna= the time to execute a memory nonaccess instruction

Nna= the number of memory nonaccess machine language instructions executed

Ta= the time to execute a memory access instruction

Na=the number of memory access machine language instructions executed

Here is the line of code that can (in addition to what I have said) be put into some of the variables, but I am just confused which lines should go to which variables? Do I have to first figure which lines are memory access meaning that store or reserve space in memory and then I would able to plug them into the formula? Any suggestions would be much appreciated. Thanks!

for(int=0; i<1000000; i++)
{
if(data[i]< 0)
data[i]= data[i] * 2;
}
Sep 11 '17 #1
1 3425 dseals22
74 64KB
@Frinavale Can you help me?
Sep 11 '17 #2