Click here to Skip to main content
12,404,478 members (75,131 online)
Click here to Skip to main content

Stats

190.5K views
590 downloads
140 bookmarked
Posted

NPerf, A Performance Benchmark Framework for .NET

, 25 Jan 2004
NPerf is a framework for benchmarking classes and methods, that tastes like NUnit.
Release
NPerf.Cons.exe
NPerf.Core.dll
NPerf.Framework.chm
NPerf.Framework.dll
NPerf.Report.dll
scpl.dll
System.Perf.dll
Releases
Unpackaged
nperf-1.1-Release
nperf
bin
Release
nperf-doc-1.1.chm
NPerf.Cons.exe
NPerf.Core.dll
NPerf.Framework.dll
NPerf.Report.dll
scpl.dll
System.Perf.dll
src
build
NAnt
i18n.xsl
ICSharpCode.SharpCvsLib.dll
ICSharpCode.SharpZipLib.dll
log4net.dll
NAnt.Contrib.Tasks.dll
NAnt.Core.dll
NAnt.DotNetTasks.dll
NAnt.exe
NAnt.NUnit.dll
NAnt.NUnit1Tasks.dll
NAnt.NUnit2ReportTasks.dll
NAnt.NUnit2Tasks.dll
NAnt.SourceControlTasks.dll
NAnt.VisualCppTasks.dll
NAnt.VSNetTasks.dll
NAnt.Win32Tasks.dll
NAnt.ZipTasks.dll
NDoc.Core.dll
NDoc.Documenter.Msdn.dll
NDoc.Documenter.NAnt.dll
NUnit-Frame.xsl
NUnit-NoFrame.xsl
nunit.framework.dll
NUnitCore.dll
toolkit.xsl
NPerf.Cons
Collections
App.ico
NPerf.Cons.cmbx
NPerf.Cons.prjx
NPerf.Core
Collections
Monitoring
Tracers
NPerf.Core.cmbx
NPerf.Core.prjx
NPerf.Framework
NPerf.Framework.cmbx
NPerf.Framework.prjx
NPerf.Report
scpl
scpl.dll
System.Perf
NPerf.Framework.chm
nperf.ndoc
nperf.png
<?xml version="1.0" encoding="utf-8" ?> 
<doc>
<remarkss>
<remarks name="PrefTestAttribute">
<para>
The Test attribute marks a specific method inside a class that has 
already been marked with the <see cref="PerfTesterAttribute"/>, 
as a performance test method. 
</para>
<para>
The method should take the tested type as parameter and return
<c>void</c>:
<code>[PerfTester(typeof(MyClass))]
public Tester
{
    [PerfTest]
    public Test(MyClass tested)
    {
       ...
    }
}</code>
</para>
</remarks>
<remarks name="PerfTesterAttribute"> 
<para>
This is the attribute that marks a class that contains performance test
methods. This attribute is contained in the NPerf.Framework namespace. 
</para>
<para>
The user must specify the type to which the performance tests are to
be applied. This type is supplied in the constructor.
</para>
</remarks>
<remarks name="PerfTearDownAttribute">
<para>
The PerfTearDown attribute marks a specific method inside a class, that has 
already been marked with the <see cref="PerfTesterAttribute"/>, 
as a test teardown method. 
</para>
<para>
The method must take the tested type as parameter.
</para>
</remarks>
<remarks name="PerfSetUpAttribute">
<para>
The SetUp attribute marks a specific method inside a class that has 
already been marked with the <see cref="PerfTesterAttribute"/>, 
as a test setup method. 
</para>
<para>
The method takes the test index and the tested type as parameter.
The method must return void.
</para>
<para>
Because of .Net JIT, a first run must be made on the test in order to avoid the
overhead of the compilation. In this case, the testIndex is set to -1.
</para>
</remarks>
<remarks name="PerfRunDescriptorAttribute">
<para>
The <see cref="PerfRunDescriptorAttribute"/> tags a method that returns
the feature tested value in function of the run index.
</para>
<para>
For instance, if you are testing collections with increasing number of elements,
the feature tested value is the number of elements processed.
</para>
</remarks>
</remarkss>
<examples>
<example name="PerfTesterAttribute">
In this example, we mark a class to benchmark sorter algorithms defined by the <c>ISorter</c> interface,
and that should run 3 times:
<code>using NPerf.Framework;

[PerfTester(typeof(IDictionary),10)]
public class SorterTester
{
   ...
}</code>
A test description, and a featured value description can be specified in the attribute
constructor:
<code>[PerfTester(typeof(IDictionary),10, Description="...", FeatureDescription="...")]
public class SorterTester ...
</code>
</example>
<example name="PerfTestAttribute">
In this example, we define a test method. 
<code>using NPerf.Framework;

[PerfTester(typeof(IDictionary), 10)]
public DictionaryTester
{
    [PerfTest]
    public void Test(IDictionary dictionary)
    {
       ...
    }
}</code>
</example>
<example name="PerfSetUpTearDownAttribute">
The <see cref="PerfSetUpAttribute"/> defines a method that initializes the tester and
tested object. The <see cref="PerfTearDownAttribute"/> defines a method that cleans ressources after the test has 
been executed.
<code>using NPerf.Framework;

[PerfTester(typeof(IDictionary),3)]
public DictionaryTester
{
    [PerfSetUp]
    public void SetUp(int testIndex, IDictionary dic)
    {
       // setting up the test
       ...
    }
    
    [PerfTearDown]
    public void TearDown(IDictionary dic)
    {
    }
}</code>
</example>
</examples>
</doc>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Jonathan de Halleux
Engineer
United States United States
Jonathan de Halleux is Civil Engineer in Applied Mathematics. He finished his PhD in 2004 in the rainy country of Belgium. After 2 years in the Common Language Runtime (i.e. .net), he is now working at Microsoft Research on Pex (http://research.microsoft.com/pex).

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160721.1 | Last Updated 26 Jan 2004
Article Copyright 2004 by Jonathan de Halleux
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid