Performance when accessing class members
Posted
by Dr. Acula
on Stack Overflow
See other posts from Stack Overflow
or by Dr. Acula
Published on 2010-05-19T16:34:59Z
Indexed on
2010/05/19
16:50 UTC
Read the original article
Hit count: 167
c++
I'm writing something performance-critical and wanted to know if it could make a difference if I use:
int test( int a, int b, int c )
{
// Do millions of calculations with a, b, c
}
or
class myStorage
{
public:
int a, b, c;
};
int test( myStorage values )
{
// Do millions of calculations with values.a, values.b, values.c
}
- Does this basically result in similar code? Is there an extra overhead of accessing the class members?
I'm sure that this is clear to an expert in C++ so I won't try and write an unrealistic benchmark for it right now
© Stack Overflow or respective owner