how scope affects speed
-
hi, i am getting started with a very resource intensive app, i was wondering if there is any speed difference between the following three versions of a function (assuming they are not inlined):
int func1() {return 0;} namespace testns { int func2() {return 0;} }; class testclass { static int func3() {return 0;} }; void main() { func1(); testns::func2(); testclass::func3(); }
any help is appreciated -
hi, i am getting started with a very resource intensive app, i was wondering if there is any speed difference between the following three versions of a function (assuming they are not inlined):
int func1() {return 0;} namespace testns { int func2() {return 0;} }; class testclass { static int func3() {return 0;} }; void main() { func1(); testns::func2(); testclass::func3(); }
any help is appreciatedHow you tried putting some timer code around each call, or running the code through the profiler to see?
"Take only what you need and leave the land as you found it." - Native American Proverb
-
hi, i am getting started with a very resource intensive app, i was wondering if there is any speed difference between the following three versions of a function (assuming they are not inlined):
int func1() {return 0;} namespace testns { int func2() {return 0;} }; class testclass { static int func3() {return 0;} }; void main() { func1(); testns::func2(); testclass::func3(); }
any help is appreciatedme think scopes are resolved at compilation time, and will be converted to something similar.
Maximilien Lincourt Your Head A Splode - Strong Bad
-
hi, i am getting started with a very resource intensive app, i was wondering if there is any speed difference between the following three versions of a function (assuming they are not inlined):
int func1() {return 0;} namespace testns { int func2() {return 0;} }; class testclass { static int func3() {return 0;} }; void main() { func1(); testns::func2(); testclass::func3(); }
any help is appreciatedi vote for "no effect at all: they all turn into 'jmp xxxxx' after compilation" Cleek | Image Toolkits | Thumbnail maker
-
i vote for "no effect at all: they all turn into 'jmp xxxxx' after compilation" Cleek | Image Toolkits | Thumbnail maker
Chris Losinger wrote:
they all turn into 'jmp xxxxx' after compilation
or call instructions :-)
-
hi, i am getting started with a very resource intensive app, i was wondering if there is any speed difference between the following three versions of a function (assuming they are not inlined):
int func1() {return 0;} namespace testns { int func2() {return 0;} }; class testclass { static int func3() {return 0;} }; void main() { func1(); testns::func2(); testclass::func3(); }
any help is appreciatedok, thanks guys! i assumed instance member functions are a bit slower than static functions, is this correct too?
-
ok, thanks guys! i assumed instance member functions are a bit slower than static functions, is this correct too?
zildjohn01 wrote:
is this correct too?
there's a minimal amount of extra setup required for member functions (need to push a 'this' pointer onto the stack - basically an extra parameter) before the call gets made. virtual functions will be slower because there's a function pointer lookup to deal with. Cleek | Image Toolkits | Thumbnail maker