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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T17:59:36+00:00 2026-05-11T17:59:36+00:00

Q1. What are best practices for a writing a code that does not consume

  • 0

Q1. What are best practices for a writing a code that does not consume CPU but still achieve a great performance? The question is very generic. What I seek over here is to list down different practices used for different environments? debugging tips besides process-monitor/task manager

EDIT:
I am not speaking of IO bound processes. I am speaking of CPU bound process. But, here I do not want my process to keep on hogging CPU.
If i have a 4 core machines and if i run four simple loops within a process, the CPU consumption shoots up to 400% till the application/process is running.

I am seeking here some experience on the topic which everyone would have faced some time or other. e.g. I debugged once an application was hogging CPU on Windows as it was looping continuously to search for a non-existent file.

How can I write my program in a way that two different CPU bound applications run smoothly (give a good response)?

UPDATE:
Suggestions:

  1. Write good clean code, then Profile your application and then optimize. (Thanks ted for the tip)

  2. It is easier to rewrite/redesign/refactor code than profiling and fixing it.

  3. Use a profiler to debug your application

  4. Don’t use spinlocks for threads with long waits

  5. Algorithm choice

These suggestions go a long way for the beginner to understand the concepts.

  • 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-11T17:59:36+00:00Added an answer on May 11, 2026 at 5:59 pm

    First, write good clean code. Do things the simplest way possible.
    After that, do the following repeatedly until you are satisfied with speed of the program:

    1. Profile its execution.
    2. Find the parts where it is spending the most time.
    3. Speed up those parts.

    Do not fall into the trap of perverting your code up front in the name of optimization.

    Remember Amdhal’s Law. You aren’t going to get noticeable improvements by speeding up something that is already only consuming 1% of your program’s time. You get the best bang for your optimization buck by speeding up the part your program spends the most of its time doing.

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

Sidebar

Ask A Question

Stats

  • Questions 95k
  • Answers 96k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Things still appear in the same order as they are… May 11, 2026 at 7:06 pm
  • Editorial Team
    Editorial Team added an answer The stanford link is a great reference. Generally, a view… May 11, 2026 at 7:06 pm
  • Editorial Team
    Editorial Team added an answer There is a built-in error token in yacc. You would… May 11, 2026 at 7:06 pm

Related Questions

I want to develop ASP.NET C# based MMOG (Massively multiplayer online game). I would
What is the difference between the Project and SVN workingDirectory Config Blocks in CruiseControl.NET?
I have a question about boost::shared_ptr<T> . There are lots of thread. using namespace
A) Question below is based on the assumption that controls are always binded to
I am trying to generate a report by querying 2 databases (Sybase) in classic

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.