top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Is it possible to optimize this code to reduce number of instructions performing on it?

+3 votes
718 views
int32 find_result(int64 sec)
{

    if(config == defualt_base)
    {
        uint32 H      = j * k + 1; /*(here j and k global)*/

        if((((uint32)(sec - CS - RS)) % (H * N_p * M_r))== 0) 
        {
            result = 0;
        }
    }
    else
    {
        if((((uint32)(sec - CS - RS)) % (N_p * M_r))== 0)  /*(N_p and M_r global)*/
        {
            result = 0;
        }
    }
}

This function have to be execute several times in a second, How can optimize it ? Please help me to avoid mathematical operations applying on this function?

posted Sep 6, 2016 by Suchakravarthi Sripathi

Looking for an answer?  Promote on:
Facebook Share Button Twitter Share Button LinkedIn Share Button
What is CS and RS.
Also
sec - CS - RS can be written as sec-(CS+RS). Though most compiler must be already optimizing it. Other then this I dont see any...
Hi salil,

can you provide me some tip, how do i check number of instructions performing on my particular c Program ?
I don't have any pointer as of now, but you can google to find out if there is some tool exist to find out the number of machine cycle in a code.
use gcc option -S to generate an assmebly code. that will give you an  picture of actual machine code.
HI jaganathan,

Can u able to do any optimization on above code? ( I need something to replace with arthemetic operations). Please help me if you can..
Hi salil,

Is there any system level improvement by using sec - (cs+rs) instead of (sec-cs-rs) ?
Not sure check with assembly code of both the cases...
I dont think any optimization we can do. But execution timing we can reduce by replacing % operator with bitwise operation, bcause % operator is so costly in time wise, so you can reduse it.

Similar Questions
+2 votes

The question concerns the interference. Why interference occur in the area between the sectors of the same eNB and between eNBs. The result of such interference's is the decrease of SINR and the DL throughput. Such situation is not present in uplink. Is it possible to reduce the impact of this phenomenon?

0 votes

Suppose A is represented by 1, B by 2 ...and Z by 26.

Now we are given a number, and we need to find number of possible decoding for this number. No need to consider number starts with zero.

Example:
Input – 1234,
Output – 3(ABCD, AWD, LCD)

+2 votes

I intend to write in lowest level of computer programming as a hobby, any suggestion how to start.

Tagging as C as I dont know the tag.

+2 votes

I have some C code which is using sqrt which is using a lot of processing time. Is there a way to optimize?

0 votes

Is it possible to connect database with c code, if yes then how?

If possible share the sample code for connecting to a MySQL database and run a sample query....

...