|
//=============================================================================
// System : Code Colorizer Library
// File : TextColorizerControl.cs
// Author : Jonathan de Halleux, (c) 2003
// Updated : 02/21/2007
// Compiler: Microsoft Visual C#
//
// This is used to display syntax colorized blocks of text in an HTML page.
// The original Code Project article by Jonathan can be found at:
// http://www.codeproject.com/csharp/highlightcs.asp.
//
// Modifications by Eric Woodruff (Eric@EWoodruff.us) 11/2006:
//
// Conditionalized code to remove it from release builds.
//
//=============================================================================
#if DEBUG
using System;
namespace ColorizerLibrary
{
/// <summary>
/// A timer with averaging and counting
/// </summary>
public class AvgTimer : BasicTimer
{
#region Private data members
private long totalQuantity, runNumber;
private double totalTime;
#endregion
#region Properties
/// <summary>
/// Returns the sum of timer runs
/// </summary>
/// <value>Sum of timer runs</value>
public double TotalDuration
{
get { return totalTime; }
}
/// <summary>
/// Returns the number of runs that the timer has done
/// </summary>
/// <value>Run count</value>
public long RunCount
{
get { return runNumber; }
}
/// <summary>
/// Returns a normalized time measurement
/// </summary>
/// <value>Total time divided by total quantity</value>
public double DurationPerQuantity
{
get { return (double)totalTime / (double)totalQuantity; }
}
/// <summary>
/// Returns average time per run
/// </summary>
/// <value>Total time divided by run number</value>
public double DurationPerRun
{
get { return (double)totalTime / (double)runNumber; }
}
#endregion
#region Constructors
/// <summary>
/// An averaging/normalizing timer.
/// </summary>
/// <example>In this example, we measure the time to parse a string. The string length will be passed to the
/// timer to have a sec/char time measurement.
/// <code>
/// string str;
/// AvgTimer timer = new AvgTimer();
/// //Start timer
/// timer.Start( str.Length);
/// ... // do things
/// timer.Stop();
/// result = "The processing timer per character is " + timer.DurationPerQuantity;
/// </code>
/// </example>
public AvgTimer()
{
}
#endregion
#region Public Methods
/// <summary>
/// Starts timer
/// </summary>
/// <param name="quantity">Quantity that will be processed</param>
public void Start(long quantity)
{
totalQuantity += quantity;
base.Start();
}
/// <summary>
/// Stops the timer
/// </summary>
public override void Stop()
{
base.Stop();
totalTime += this.Duration;
++runNumber;
}
/// <summary>
/// Resests internal run counter and time integrator
/// </summary>
public void Reset()
{
totalQuantity = 0;
totalTime = 0;
runNumber = 0;
}
#endregion
}
}
#endif
|
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.
Eric Woodruff is an Analyst/Programmer for Spokane County, Washington where he helps develop and support various applications, mainly criminal justice systems, using Windows Forms (C#) and SQL Server as well as some ASP.NET applications.
He is also the author of various open source projects for .NET including:
The Sandcastle Help File Builder - A front end and project management system that lets you build help file projects using Microsoft's Sandcastle documentation tools. It includes a standalone GUI and a package for Visual Studio integration.
Visual Studio Spell Checker - A Visual Studio editor extension that checks the spelling of comments, strings, and plain text as you type or interactively with a tool window. This can be installed via the
Visual Studio Gallery.
Image Map Controls - Windows Forms and web server controls that implement image maps.
PDI Library - A complete set of classes that let you have access to all objects, properties, parameter types, and data types as defined by the vCard (RFC 2426), vCalendar, and iCalendar (RFC 2445) specifications. A recurrence engine is also provided that allows you to easily and reliably calculate occurrence dates and times for even the most complex recurrence patterns.
Windows Forms List Controls - A set of extended .NET Windows Forms list controls. The controls include an auto-complete combo box, a multi-column combo box, a user control dropdown combo box, a radio button list, a check box list, a data navigator control, and a data list control (similar in nature to a continuous details section in Microsoft Access or the DataRepeater from VB6).
For more information see
http://www.EWoodruff.us