Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

NTime - Performance unit testing tool

, 30 Mar 2006
An article on a performance testing tool to test an application against its performance.
ntime_demo.zip
Installer
1.1
NTimeSetup.msi
Setup.Exe
Setup.Ini
2.0
NTimeSetup.msi
setup.exe
ntime_sdk.zip
ntime_src.zip
src
Framework
License.rtf
ntime.snk
NTimeConsole
App.ico
NTimeGUI
folder.bmp
folder2.bmp
gray.bmp
green.bmp
NTime.ico
red.bmp
yellow.bmp
NTimeSetup
NTimeSetup.vdproj
PerformanceTests
Readme.rtf
ntime_src_11.zip
NTime_src_1.1
Framework
.VPUML
.history
.historyinfo_NTime.Framework.dll
NTime.Framework.dll.vpp.v1
NTime.Framework.dll.vpp
bin
Release
NTime.Framework.dll
ModelSupport
default.txvpck
NTime
Framework
Framework.txvpck
NTime.txvpck
mssccprj.scc
NTime.Framework
NTime.Framework.dll.csproj.user
NTime.Framework.dll.csproj.vspscc
vssver.scc
ntime.snk
NTimeAddin
bin
Release
NTimeAddin.dll
NTimeAddin.tlb
NTimeAddin.csproj.user
NTimeAddinSetup
NTimeAddinSetup.vdproj
NTimeConsole
App.ico
bin
Release
NTime.exe
NTimeConsole.exe
ModelSupport
mssccprj.scc
NTime.csproj.user
NTime.csproj.vspscc
vssver.scc
NTimeGUI
.VPUML
.history
.historyinfo_NTimeGUI
NTimeGUI.vpp.v1
NTimeGUI.vpp
bin
Release
NTimeGUI.exe
folder.bmp
folder2.bmp
gray.bmp
green.bmp
ModelSupport
default.txvpck
NTime
GUI
GUI.txvpck
NTime.txvpck
mssccprj.scc
NTime.ico
NTimeGUI.csproj.user
NTimeGUI.csproj.vspscc
out
doc
doc-files
default.gif
gendoc.gdc
model-tree
false.gif
model.tree
ST_Attribute.gif
ST_Class Diagram.gif
ST_Class.gif
ST_Operation.gif
ST_Package Diagram.gif
ST_Package.gif
ST_Project.gif
true.gif
navigation.jar
NTime
doc-files
NTime.gif
GUI
doc-files
Class Diagram1.gif
GUI.gif
red.bmp
vssver.scc
yellow.bmp
NTimeSetup
mssccprj.scc
NTimeSetup.vdproj
NTimeSetup.vdproj.vspscc
vssver.scc
PerformanceTests
bin
Release
PerformanceTests.dll
PerformanceTests.ntime
ModelSupport
PerformanceTests
mssccprj.scc
PerformanceTests.csproj.user
PerformanceTests.csproj.vspscc
vssver.scc
ntime_src_20.zip
NTime_src_2.0
Framework
.VPUML
.history
.historyinfo_NTime.Framework.dll
NTime.Framework.dll.vpp.v1
NTime.Framework.dll.vpp
bin
Release
NTime.Framework.dll
ModelSupport
default.txvpck
NTime
Framework
Framework.txvpck
NTime.txvpck
mssccprj.scc
NTime.Framework
NTime.Framework.dll
NTime.Framework.dll.csproj.user
NTime.Framework.dll.csproj.vspscc
Properties
vssver.scc
NTimeConsole
App.ico
bin
Release
NTime.exe
NTime.Framework.dll
NTimeConsole.exe
ModelSupport
mssccprj.scc
NTime.csproj.user
NTime.csproj.vspscc
Properties
vssver.scc
NTimeGUI
.VPUML
.history
.historyinfo_NTimeGUI
NTimeGUI.vpp.v1
NTimeGUI.vpp
bin
Release
NTime.Framework.dll
NTimeGUI.exe
folder.bmp
folder2.bmp
gray.bmp
green.bmp
ModelSupport
default.txvpck
NTime
GUI
GUI.txvpck
NTime.txvpck
mssccprj.scc
NTime.ico
NTimeGUI.csproj.user
NTimeGUI.csproj.vspscc
out
doc
doc-files
default.gif
gendoc.gdc
model-tree
false.gif
model.tree
ST_Attribute.gif
ST_Class Diagram.gif
ST_Class.gif
ST_Operation.gif
ST_Package Diagram.gif
ST_Package.gif
ST_Project.gif
true.gif
navigation.jar
NTime
doc-files
NTime.gif
GUI
doc-files
Class Diagram1.gif
GUI.gif
Properties
red.bmp
vssver.scc
yellow.bmp
NTimeSetup
mssccprj.scc
NTimeSetup.vdproj
NTimeSetup.vdproj.vspscc
vssver.scc
PerformanceTests
bin
Release
NTime.Framework.dll
PerformanceTests.dll
PerformanceTests.ntime
ModelSupport
PerformanceTests
mssccprj.scc
PerformanceTests.csproj.user
PerformanceTests.csproj.vspscc
Properties
vssver.scc
#region Copyright (c) 2004, Adam Slosarski
/************************************************************************************
'
' Copyright  2004 Adam Slosarski
'
' This software is provided 'as-is', without any express or implied warranty. In no 
' event will the authors be held liable for any damages arising from the use of this 
' software.
' 
' Permission is granted to anyone to use this software for any purpose, including 
' commercial applications, and to alter it and redistribute it freely, subject to the 
' following restrictions:
'
' 1. The origin of this software must not be misrepresented; you must not claim that 
' you wrote the original software. If you use this software in a product, an 
' acknowledgment (see the following) in the product documentation is required.
'
' Portions Copyright  2004 Adam Slosarski
'
' 2. Altered source versions must be plainly marked as such, and must not be 
' misrepresented as being the original software.
'
' 3. This notice may not be removed or altered from any source distribution.
'
'***********************************************************************************/
#endregion
using System;
using System.Windows.Forms;
using NTime.Framework;
using System.Collections;


namespace NTime.Tests
{
	/// <summary>
	/// This is a tested class.
	/// </summary>
	[TimerFixture]
	public class TestClass
	{
		[TimerFixtureSetUp]
		public void GlobalSetUp()
		{
			// initialize one-time initialization data in this testfixture.

			// Configuration settings work as well.
//			string test = System.Configuration.ConfigurationSettings.AppSettings["testConfig"];
//			System.Windows.Forms.MessageBox.Show(test);

			// Even dynamically loaded assemblies do work.
//			System.Reflection.Assembly a = System.Reflection.Assembly.LoadWithPartialName("PerformanceTests");
//			MessageBox.Show(a.ToString());
//			foreach(System.Type t in a.GetTypes())
//			{
//				MessageBox.Show(t.FullName);
//			}
		}

		[TimerFixtureTearDown]
		public void GlobalTearDown()
		{
			// release one-time initialized data in this testfixture.
		}

		[TimerSetUp]
		public void LocalSetUp()
		{
			// initialize data for every test found in this testfixture class
		}

		[TimerTearDown]
		public void LocalTearDown()
		{
			// release data for every finished test found in this testfixture class
		}

		[TimerHitCountTest(300, Threads = 3, Unit = TimePeriod.Second)]
		public void WebRequest()
		{
			// invoke some code from real application to test its functions against specified performance.
			// in example we will keep our fictional web server's response at 10 milliseconds
			if(System.Threading.Thread.CurrentThread.Name == "NTimeThread_0")
				System.Threading.Thread.Sleep(5);
			else if(System.Threading.Thread.CurrentThread.Name == "NTimeThread_1")
				System.Threading.Thread.Sleep(8);
			else
				System.Threading.Thread.Sleep(10);
		}

		[TimerDurationTest(20, Unit = TimePeriod.Millisecond)]
		public void GameScreenFlicking()
		{
			// we want to calc game AI, 3d engine and other stuff to keep it running at 50Hz vertical screen sync.
			System.Threading.Thread.Sleep(5);
		}

		[TimerDurationTest(10, Unit = TimePeriod.Millisecond)]
		[TimerIgnore("This test is disabled, because test specification or algorithm details are unknown for now.")]
		public void SuperSortAlgorithm()
		{
			// code here will not be profiled until TimerIgnore flag was removed.
		}

		[TimerCounterTest("Process", "% Processor Time", Threads = 1, InstanceName = "*", MinimumValue = 0, MaximumValue = 50)]
//		[TimerCounterTest("Process", "Handle Count", Threads = 1, InstanceName = "NTime", MinimumValue = 0, MaximumValue = 50)]
		public void ProcessorUsage()
		{
			// we want to see whether our application is optimized to work with minimal CPU usage.
			for(int i = 0; i < 3; i++)
			{
				System.Threading.Thread.Sleep(1000);
			}
		}
	}
}

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

AdamSlosarski
Web Developer
Poland Poland
Born in Poland, living there as employeed developer, in free time writing much .net stuff and designing applications.

| Advertise | Privacy | Mobile
Web01 | 2.8.140821.2 | Last Updated 31 Mar 2006
Article Copyright 2004 by AdamSlosarski
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid