Monday 15 June 2015

Why does this C++ function takes 4 time as much as a c function -


I am considering using c ++ for a performance critical application. I thought that there will be comparative running time between both C and C ++. However I think that takes the C ++ function & gt; Comparative Si Snippet to run it 4 times.

When I made a desemblable, I ended (), ++,! = All functions call. Is it possible to make them (at least some of them) inline?

Here is the C ++ code:

  Type-Effect Structure pfx_s {start unsigned integer; Unsigned end-end; Unsigned counts; } Pfx_t; Typedef std :: list & lt; Pfx_t * & gt; Pfx_list_t; Int eval_one_pkt (pfx_list_t * cfg, unsigned int ip_addr) {const_list_iter_t iter; (ITR = cfg-> start (); iarar = cfg-> and (); IAR ++) {if (((* et) -> start   

and it is equivalent to c code:

  int eval_one_pkt (cfg_t * cfg, unsigned int ip_addr) {pfx_t * pfx; TAILQ_FOREACH (PFX, & amp; cfg-> pfx_head, next) {If ((pfx-> start  end> Ip_addr)) {PFX-> Count ++; Return 1; }} Return 0; }    

It is worth noting that the data structure you use is completely Are not equivalent. Your C-list has been implemented as a list of immediate elements. Your C ++ list has been implemented as the indicators list for the actual elements. Indicator However, it can affect the functionality of code to its bad memory area.

I think you have timed out the debug version of your code, perhaps it is compiled with the debug version of the library.

No comments:

Post a Comment