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 8016719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:37:05+00:00 2026-06-04T20:37:05+00:00

Is any difference (in speed of my program – execution time) between?? 1 st

  • 0

Is any difference (in speed of my program – execution time) between??

1 st option:

 private void particleReInit(int loop)
        {
            this.particle[loop].active = true;
            this.particle[loop].life = 1.0f;
            this.particle[loop].fade = 0.3f * (float)(this.random.Next(100)) / 1000.0f + 0.003f; 
            this.particle[loop].r = colors[this.col][0];    // Select Red Rainbow Color
            this.particle[loop].g = colors[this.col][1];    // Select Red Rainbow Color
            this.particle[loop].b = colors[this.col][2];    // Select Red Rainbow Color
            this.particle[loop].x = 0.0f;
            this.particle[loop].y = 0.0f;
            this.particle[loop].xi = 10.0f * (this.random.Next(120) - 60.0f);
            this.particle[loop].yi = (-50.0f) * (this.random.Next(60)) - (30.0f);
            this.particle[loop].xg = 0.0f; 
            this.particle[loop].yg = 0.8f; 
            this.particle[loop].size = 0.2f;
            this.particle[loop].center = new PointF(particleTextures[0].Width / 2, particleTextures[0].Height / 2);

    }

2 nd option:

Particle p = particle[loop];
p.active = true;
p.life = 1.0f;
...

Where Particle particle[] = new Particle[NumberOfParticles]; is just an array of Particles which have some properties like life, position.

I’m doing it in Visual Studio 2010 Like WFA (Windows Form Aplication) and need to enhance performance (we’re not able to use OpenGL, so for more particles my program tends to be slow).

  • 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-06-04T20:37:08+00:00Added an answer on June 4, 2026 at 8:37 pm

    I would certainly expect there to be a difference in speed – it’s doing more work, after all. Another thread may have changed the contents of the array between statements, which may (or may not) be visible within this thread. If these are properties rather than fields, the property setter could even conceivably change the values in the array within the same thread, which would have to be visible.

    Whether the difference in speed is significant or not is a different matter, and one that we can’t judge.

    More importantly, I’d say that the second form is clearer than the existing code.

    In fact, if this is actually meant to be reinitializing the whole element, I’d actually create a new Particle and then assign that to the element:

    particle[loop] = new Particle {
        active = true,
        life = 1f,
        // etc
    };
    

    … or create a separate method/constructor which created a particle in an appropriate state.

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

Sidebar

Related Questions

Is there any execution speed difference between the following two lines of code? I
Is there any difference in performance ( speed wise ) between a synchronous request
Is there any noticeable difference in speed between these 2 scenarios? Scenario 1: I
Is there any tangible difference (speed/efficiency) between these statements? Assume the column is indexed.
Is there any speed difference between these two versions? <?php echo $var; ?> <?=$var?>
Is there any difference between these tow pieces of code & which approach is
1)Is there any difference between these two keywords for the elements of collections??( Copy
Is there any difference between type casting & type conversion in c++.
Is there any difference between these two LINQ statements: var query = from a
Is there any difference between following two ways of creating an object. Student s1

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.