Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6836737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:23:30+00:00 2026-05-26T23:23:30+00:00

How much does using the dot operator to access some data cost speed-wise? Eg:

  • 0

How much does using the dot operator to access some data cost speed-wise? Eg:

struct A{
    public:
       A(): a(0){};
       int a;
};

int main(){
       A obj;
       int b = 0;

       cout << obj.a;  // How much slower is this
       cout << b;      // Than this...?

       return 0;
}

I know I should benchmark, but are there any general understandings here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T23:23:31+00:00Added an answer on May 26, 2026 at 11:23 pm

    Let’s take a look at dissasembled code:

           cout << obj.a;  // How much slower is this
    0041161D  mov         esi,esp 
    0041161F  mov         eax,dword ptr [obj] 
    00411622  push        eax  
    00411623  mov         ecx,dword ptr [__imp_std::cout (41A34Ch)] 
    00411629  call        dword ptr [__imp_std::basic_ostream<char,std::char_traits<char> >::operator<< (41A35Ch)] 
    0041162F  cmp         esi,esp 
    00411631  call        @ILT+430(__RTC_CheckEsp) (4111B3h) 
           cout << b;      // Than this...?
    00411636  mov         esi,esp 
    00411638  mov         eax,dword ptr [b] 
    0041163B  push        eax  
    0041163C  mov         ecx,dword ptr [__imp_std::cout (41A34Ch)] 
    00411642  call        dword ptr [__imp_std::basic_ostream<char,std::char_traits<char> >::operator<< (41A35Ch)] 
    00411648  cmp         esi,esp 
    0041164A  call        @ILT+430(__RTC_CheckEsp) (4111B3h) 
    

    This was compiled without optimizations. And even so, they take the same time.
    With optimizations, the code is shorter, but still remains largely the same:

           cout << obj.a;  // How much slower is this
    00401000  mov         ecx,dword ptr [__imp_std::cout (40203Ch)] 
    00401006  push        0    
    00401008  call        dword ptr [__imp_std::basic_ostream<char,std::char_traits<char> >::operator<< (402038h)] 
           cout << b;      // Than this...?
    0040100E  mov         ecx,dword ptr [__imp_std::cout (40203Ch)] 
    00401014  push        0    
    00401016  call        dword ptr [__imp_std::basic_ostream<char,std::char_traits<char> >::operator<< (402038h)] 
    

    So for your snippet, the performance is identical. Small differences might occur on different compilers, but the overhead will always be negligible or 0.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How much difference does dedicated graphics and HDD speed matter when using virtual machines?
Using an Oracle temporary table does not generate much redo log as a normal
Should I always be using this method when rendering? Does it slow down much
How much of a difference does using tinyint or smallint (when applicable) instead of
How much does less.js impact the speed of a site? For standardization purposes ,
How much does the garbage collector affect performance when working with lots of objects
What do I need to download to make flash games and how much does
How much hardware understanding does one need to fully comprehend Operating System and Computer
Visual Studio 2008 does a much better job of detecting and adding controls from
The description of CoLoadLibrary() says it does pretty much the same as LoadLibraryEx() -

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.