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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:29:46+00:00 2026-06-12T14:29:46+00:00

In my project I have a class where execution time is the first goal.

  • 0

In my project I have a class where execution time is the first goal. For it I don’t care much about maintenance, order and so on. At least I didn’t care till yesterday… Now I’m in situation where I have to be a little worried about it, too.

I have a class, say A, which performs multiple scans on images coming from a camera, i.e. a variable width window scans them in real time.



    class A{  
    // methods and attributes of A:  
    ...  
    void runiterator(){  
      ...  
    for{    // change window’s dimension  
      for{  // rows  
       for{ // columns  
          // many lines of code of operations to be executed for each window at each position  
          ...      
       }  
      }   
     }  
    }  
    }; 

Performance shows already a little delay, but I could solve it skipping a limited area of the image. Furthermore I have a second function, say B, which has exactly the same scheme as A, and executes different operations on each scan (and luckily is much faster than A).

Well, now it is time to join all the operations to benefit significantly the overall result. Only that the code would really become messed-up, huge and mixing things that are really different. I thought to define a class X that does the iterations and at each scan executes function calls to one function in A_new and one in B_new. But I’m worried that about 200000×2 function calls per image would result in loss in performance.

What is your advice?

EDIT
With class X that only calls Anew (so it could only be compared to what now is A), I get on the average, out of many repetitions:

Time for executing X on a series of 56 images = 6.15 s
Time for executing A on thesame series of 56 images = 5.98 s

It seems that my suspects were not so naive.
The difference is about 3%, not so much, but still sorry for the loss.

With __forceinline time is 5.98 s for X as well, but I would prefer not relying on it.

I think that code is optimized and margins for further improvements are very little.
Indeed it does a lot of stuff on images in a relatively short time.
Processing data sequentially is not possible in class A because it is based on the values coming from the images which are impredictable. This is the reason why class B (that manages to do it) is much faster.

  • 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-12T14:29:47+00:00Added an answer on June 12, 2026 at 2:29 pm

    You really have to measure that it causes performance problems before worrying about it.

    If there is a problem, try to do it with templates. Write the two variants of the functions, then use them as functors in your function template which does the iteration. You’ll instantiate both versions, and call the appropriate one. The compiler should inline the calls (but better verify this).

    I used this on medical image manipulation and it worked like a charm.

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

Sidebar

Related Questions

Hope I'm asking this correctly: I have a project Projects.Client I have my class
I have a class project where I am using a VB.Net form to search
I have a Class Library project and MVC project in the one solution. My
I have a class library project that references the version 4.1 Microsoft.Practices.Common dll. I
I have a class named project with the following data members. class Project {
I have a class library project which contains some content files configured with the
I have a class template in a c++ project: template<class RequestHandler = DefaultRequestHandler> class
I have a webservice project (old asmx technology) in which I have a class
I have a class, which is part of a code library project that was
I have in my WPF project file RssInfo.cs in which I have public class

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.