Tool/software: TI C/C++ Compiler
On the TMS320F28379D,
what is the runtime difference between direct public var acess
foo = myClass.var;
and using getter-methods by making var private
foo = myClass.get_var();
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Tool/software: TI C/C++ Compiler
On the TMS320F28379D,
what is the runtime difference between direct public var acess
foo = myClass.var;
and using getter-methods by making var private
foo = myClass.get_var();
If you build with the compiler option --opt_level=2 or higher, this ...
Marcel Kummer said:foo = myClass.get_var();
... is often inlined, and all the overhead is avoided.
Thanks and regards,
-George
At my previous post I compiled at opt-lvl 00
Now I tried the same with opt-lvl 02.
With 1.000.000 iterations diong
var = XXX;
the needed cycles (including the for loop cycles) are:
XXX cycles
local_private.get_var(): 12.000.000
global_privat.get_var(): 12.000.000
local_public.var: 12.000.000
global_public.var: 12.000.000
local_variable: 12.000.000
global_variable: 15.000.000 <- no idea why
local_struct.var: 12.000.000
global_struct.var: 12.000.000
Marcel Kummer said:global_variable: 15.000.000 <- no idea why
Accessing a global variable on a C28x device requires the overhead of loading the upper bits of the address in the data page (DP) register.
Thanks and regards,
-George