Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / CLR / July 2006

Tip: Looking for answers? Try searching our database.

Boosting priority of an application for a performance unit test

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Matt Adamson - 29 Jun 2006 14:12 GMT
I've created some simple performance tests within the NUnit test framework
to test the performance of various core business object calls e.g. creating
invoices / purchase orders e.t.c. and updating them. The tests basically
need to assert that the time to say create 1000 documents is less than a
configurable amount set by the machine through the app.config file. e.g. 500
ms.

Obviously other processes running may effect the timing slightly so I'd like
to minimise this as much as possible whilst the tests are executing. Would
using the following be appropriate here.

1) Process.PriorityBoostEnabled property
2) Process.PriorityClass
3) Thread.Priority.

The intention would be to change the priority in a method which is run
before all unit test methods are executed and then revert back to the old
behaviour when this is finished.

Thoughts?
Greg Young - 30 Jun 2006 21:15 GMT
Boosting your priority will work (I believe through all of those means) but
there will still be things that take priority over you (such as device
drivers).

I am however curious why you are creating "unit tests" for these items as
they are not really unit tests. The fact that you are needing to elevate
your process privilege shows the issue with this type of test being a unit
test. Performance tests as these should only be run in a controlled
environment where the contract would hold true (what happens if I as a
developer choose to run on a pentium 200). As an example you mention that it
should be able to create 1000 documents in x seconds ... That X seconds is
highly dependent upon the environment it is being run on.

The other problem with these types of tests is that they tend to take a
significant amount of time. Because running a single test is fairly
innacurate we often run 1000 or more iterations. By making these items unit
tests we unnecesarily add to the code-test cycle time which is what you want
to be minimal (increased productivity)

The generally accepted way of doing performance tests is to have a machine
that specifically runs the tests (and nothing else). Generally this machine
is vanilla as possible and has nothing else running on it (in an ideal
world). Integration/performance tests are then run periodically run on this
machine (often times nightly depending on system size).

HTH

Greg Young
MVP - C#
http://codebetter.com/blogs/gregyoung

> I've created some simple performance tests within the NUnit test framework
> to test the performance of various core business object calls e.g.
[quoted text clipped - 16 lines]
>
> Thoughts?
Matt Adamson - 02 Jul 2006 14:07 GMT
Thanks for your thoughts Greg

I have created unit tests for the sole purpose of attempting to catch
developers

a) Making database modifications e.g. creating triggers, indexes, which
would slow the creation of say invoices down by an unacceptable margin e.g.
20%. I could quite easily imagine a developer creating a complex trigger and
inadvertently not thinking about creation time.
b) Making code modifications to the say invoice business object to add a
complex business rule which slowed creation down by 50%.

Obviously if an existing client is getting 10000 invoices imported in a 1
hour time window and they only have 1 hour 20 minutes say, if a patch was
applied was increased this to 1 hours 30 minutes they may have a serious
issue.

By adding the performance test of creating x documents in y seconds I have
tried to encompass a test which would break the cruise control build if the
performance went to an unacceptable margin. I appreciate each machine will
have a completely different time which is why I made the timings
configurable e.g. the config file of the unit test assembly has entries

<add key="SP_PERF_PO_1-MaxTimeMs" value="400" />
<add key="SP_PERF_PO_2-MaxTimeMs" value="600" />

This file will be managed in VSS so if any developers have to increase the
time to get it to pass on our build server, we have full history of this.
The unit tests create a large selection of docs e.g. 1000 so should see any
inconsistensies in times.

I am therefore hoping the various raises of elevating process / thread
priority here would help bring about a bit more consistency to my results
and ensure the unit tests don't fail unexpectedly because of other factors
on the machine.

Thoughts?

> Boosting your priority will work (I believe through all of those means)
> but there will still be things that take priority over you (such as device
[quoted text clipped - 47 lines]
>>
>> Thoughts?
Greg Young - 02 Jul 2006 18:41 GMT
This will kill your developer performance to have developers running these
tests. Let's say your average test takes 3 seconds and you have 100
performance tests ... your unit tests will now take 5 minutes to run this
obviously kills your cycle time. The result is that developers will not run
the tests.

Running tests like these is a fairly controlled environment (i.e. running
nightly on your CI server) makes alot more sense.

You bring up another point that makes things difficult in that you are also
integrating with other processes (whatever SQL Server you happen to be
using). Is this server running on the same machine (if not you are likely
testing network latency). What about the load of this server during ther
testing period (i.e. scheduled jobs).

The way I do this is I have a set of performance tests which are run on an
integration server (my integration server does almost nothing at night, i.e.
scheduled jobs etc so it is a good place to run tests). I have thresholds
setup for an allowable delta due to outside variables. If this threshold is
crossed it will generate an error report.

Cheers,

Greg

> Thanks for your thoughts Greg
>
[quoted text clipped - 86 lines]
>>>
>>> Thoughts?
Matt Adamson - 02 Jul 2006 22:34 GMT
All unit tests are forced to be run by the CI server ( Cruise Control .NET )
and taking an extra 5 minutes or so to run additional performance is not an
issue for us. I would rather spend the 5 minutes rather than risk getting
slower performant code released to our clients.

However currently our unit tests are executed after any code changes are
detected in VSS. In light of what you say though I think it would be better
to schedule these tests to not run on every build but only at a scheduled
time e.g. 1 in the morning. As the server is used by others for a source
control repository, it can be utilised at random times.

I appreciate your thoughts however you haven't answered my question on the
way to boost the priority of processes using the 3 methods mentioned, or are
you saying you should never do this?

Cheers

Matt

> This will kill your developer performance to have developers running these
> tests. Let's say your average test takes 3 seconds and you have 100
[quoted text clipped - 113 lines]
>>>>
>>>> Thoughts?
Greg Young - 02 Jul 2006 23:22 GMT
I am saying you probably shouldn't do this but that I believe all mechanisms
would work (the thread priority probably being the best method as you can
spawn the tests on a new thread and only grant that thread higher priority).
The problem with boosting your priority is that there are still things at a
higher priority so it is only one step towards making things more
deterministic.

Cheers,

Greg

> All unit tests are forced to be run by the CI server ( Cruise Control
> .NET ) and taking an extra 5 minutes or so to run additional performance
[quoted text clipped - 132 lines]
>>>>>
>>>>> Thoughts?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.