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

  • Home
  • SEARCH
  • 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 6107219
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:09:53+00:00 2026-05-23T14:09:53+00:00

Is there a performance issue using static variables in function calculations, does it affect

  • 0

Is there a performance issue using static variables in function calculations, does it affect speed of function execution, as static variables are initialized only once?

Question is for a highly repetetive calling optimizations.

Consider this example

int calcme(int a, int b)
{
 static int iamstatic = 20;
 return a*iamstatic + b;
}

The reason to use static is to hope, that iamstatic will not be put on stack every time a function is called and it is designed to change if needed. (Static variable change code is ommited)

  • 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-23T14:09:54+00:00Added an answer on May 23, 2026 at 2:09 pm

    To my opinion you might reduce performance. When you use static, the memory is located at the bss part for the program. When the function is called it a access two different locations, the function memory and the parameter memory. If it is local then you may gain performance due to localization, when all parameters are at the same cache line, that is when the cpu read memory it reads a full cache line (16 bytes is a common size of line), you read all the data in one memory access into the cache.

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

Sidebar

Related Questions

Is there any performance issue to be aware about using this sql statement generated
My question is related to a performance issue I'm experiencing using the context module
I'm wondering if there are any negative performance issues associated with using a Singleton
we have some performance issue with a program, I traced tsql using sql server
Is there any difference between using AcceptEx direct call or using function pointer obtained
Is there a overhead or performance issue in passing whole object vs passing primitive
I am having a slight performance issue with inline function. Consider the following code:-
Is there a performance penalty when using a SecurityManager? I need the following: public
Are there performance issues when retrieving and filtering data from views than from tables
Are there any performance issues with registering a number of routes with the routing

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.