|
using System;
using System.Collections.Generic;
using System.Diagnostics;
namespace SortTests
{
public class ProcesserTime
{
private TimeSpan StartTime;
private TimeSpan EndTime;
private TimeSpan RunningTime;
private Process _proc;
public ProcesserTime(Process p)
{
_proc = p;
StartTime = p.TotalProcessorTime;
}
public void StartNew()
{
RunningTime = TimeSpan.Zero;
StartTime = _proc.TotalProcessorTime;
}
public void Stop()
{
EndTime = _proc.TotalProcessorTime;
RunningTime += EndTime - StartTime;
}
public void Start()
{
StartTime = _proc.TotalProcessorTime;
}
public long ElapsedMilliseconds
{
get
{
return (long)(RunningTime.TotalMilliseconds);
}
}
public long ElapsedTicks
{
get
{
return RunningTime.Ticks;
}
}
}
}
|
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.
Dan Randolph is currently a Web Applications Developer with Delcan. Mr. Randolph has a B.S. dergee in Computer Science from the University of Wyoming. He is an active member of the Denver Visual Studio User Group. You can find him posting in the forums on [code.]msdn.microsoft.com and Code Project.