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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T21:33:49+00:00 2026-05-15T21:33:49+00:00

I’ve been starting to write many more unit tests for my code (something I

  • 0

I’ve been starting to write many more unit tests for my code (something I should have been doing for much longer,) as well as use code profilers such as EQATEC’s to identify bottle necks. I’m wondering if there’s a correct method for monitoring performance in unit tests?

Obviously, a code profiler would be best for optimization, but what I’m really looking for is a way to make sure my most recent changes didn’t accidentally kill my performance (by calling redundant functions, etc.,) even if it didn’t break any of the logic.

My first thought is to run my method (for example, an insert or some sort) many times to come up with the number of ticks it usually takes. Then write a unit test that will repeat the method calls, then Assert(elapsedTicks < magicNumberOfTicks). This seems too arbitrary, though, and I’m wondering what other developers have used in this situation?

  • 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-15T21:33:50+00:00Added an answer on May 15, 2026 at 9:33 pm

    I would really suggest have separate regression tests and unit tests. The purpose of unit tests is code confidence, will it work. They should be quick and simple. To do real performance testing you need a large enough sample size to make the results worth while. Doing this in unit tests would make the unit tests take too long, and then you may feel the need to not run them all the time because they take too long.

    For regression testing though a good tool to use (i know there are probably better tools) but a simple excel macro should be sufficient. And you have the added bonus of already having your data in a spread sheet that you can easily compare runs for many tests.

    But if you still want to performance testing into your unit tests. The magic number idea might be your best idea, assuming the assert error message includes the expected and actual time that will give you a quick indication of how far off the run times are as well.

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

Sidebar

Ask A Question

Stats

  • Questions 461k
  • Answers 461k
  • 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 If you need a common base for those (.project, .classpath,… May 16, 2026 at 12:13 am
  • Editorial Team
    Editorial Team added an answer I need to know ILogManager the implementation class If I… May 16, 2026 at 12:13 am
  • Editorial Team
    Editorial Team added an answer Since you have both client and server programs, you can… May 16, 2026 at 12:13 am

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.