Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #5482

Re: efficient function call

From yatremblay@bel1lin202.(none) (Yannick Tremblay)
Newsgroups comp.lang.c++
Subject Re: efficient function call
Date 2011-05-25 10:38 +0000
Organization A noiseless patient Spider
Message-ID <irim81$v8d$1@dont-email.me> (permalink)
References <b77d43d1-0865-4c3d-9179-6cda0ff992c1@m40g2000vbt.googlegroups.com> <4f5eb13b-72c1-443e-ba62-03fd2fd89fbb@s16g2000prf.googlegroups.com> <irgvln$mg4$1@dont-email.me> <5b9040f8-e35b-4cb0-95c8-1b89838f1da9@s14g2000vbi.googlegroups.com>

Show all headers | View raw


In article <5b9040f8-e35b-4cb0-95c8-1b89838f1da9@s14g2000vbi.googlegroups.com>,
hamze  <hamze60@gmail.com> wrote:
>
>thanks alot for your guides, I think my problem solved.
>I used inline function instead of macro. I also used 'call by
>reference' to reduce time overhead.
>as I measured now my code is as fast as a macro, while using a "not
>inline function" caused not acceptable runtime.
>the second good and also strange thing is that my code size is also
>just a little bigger than using "not inline function", while macro
>made my code very very big. I dont know why but perhaps compiler did
>something good! ( optimization was also off!! )
>and the third good thing is that I don't have strange error cause by
>optimization on macros anymore!
>
>thanks allot for your help

Sorry but you did not solve any real problem.  You only solved an
imaginary problem that you thought existed but didn't.

Profiling with "optimisation off" is a total waste of time and
efforts.  You are lying to yourself.

If execution speed is of importance to you, then you must let the
compiler do its job and optimise.  All you did was demonstrate that
your particular compiler with the particular options that you use when
you compile on what you call "optimisation off" still inline functions
that are explicitely declared as inline.  Any compiler worth its salt
will inline small functions the moment you turn on optimisation.

When profiling, you must do it in the conditions closest to real
condition and try to make your measuring tools have as little effect
as possible to the code.  Turning off optimisation can easily slow
down a program by an order of magnitude.

Yannick


Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

efficient function call hamze <hamze60@gmail.com> - 2011-05-24 05:52 -0700
  Re: efficient function call Victor Bazarov <v.bazarov@comcast.invalid> - 2011-05-24 09:52 -0400
    Re: efficient function call yatremblay@bel1lin202.(none) (Yannick Tremblay) - 2011-05-24 18:28 +0000
    Re: efficient function call hamze <hamze60@gmail.com> - 2011-05-24 11:49 -0700
      Re: efficient function call Victor Bazarov <v.bazarov@comcast.invalid> - 2011-05-24 15:07 -0400
        Re: efficient function call hamze <hamze60@gmail.com> - 2011-05-25 00:37 -0700
          Re: efficient function call yatremblay@bel1lin202.(none) (Yannick Tremblay) - 2011-05-25 10:38 +0000
            Re: efficient function call hamze <hamze60@gmail.com> - 2011-05-25 11:08 -0700
              Re: efficient function call Dombo <dombo@disposable.invalid> - 2011-05-25 21:38 +0200
              Re: efficient function call yatremblay@bel1lin202.(none) (Yannick Tremblay) - 2011-05-26 11:44 +0000
                Re: efficient function call Edek <edek.pieITAKNIECZYTAM@gmail.com> - 2011-05-26 15:53 +0200
                Re: efficient function call yatremblay@bel1lin202.(none) (Yannick Tremblay) - 2011-05-27 08:31 +0000
                Re: efficient function call Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-05-27 13:45 +0000
                Re: efficient function call Edek <edek.pieITAKNIECZYTAM@gmail.com> - 2011-05-27 16:17 +0200
                Re: efficient function call Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-05-27 22:38 +0000
                Re: efficient function call Edek <edek.pieITAKNIECZYTAM@gmail.com> - 2011-05-27 16:39 +0200
      Re: efficient function call Joshua Maurice <joshuamaurice@gmail.com> - 2011-05-24 14:30 -0700
        Re: efficient function call hamze <hamze60@gmail.com> - 2011-05-25 00:39 -0700
      Re: efficient function call hamze <hamze60@gmail.com> - 2011-05-25 00:20 -0700

csiph-web