This is a quick reference for how to check execution time in C#. This may be helpful to others but basically keeping it for my reference; as many times when needed it I need to Google it. Following code is the one when I implemented the Zipping Assembly. To test which implementation is faster I used it.
Need to reference System.Diagnostics but the implementation is quiet simple.
Need to reference System.Diagnostics but the implementation is quiet simple.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Archive;
using System.Diagnostics;
using System.Threading;
namespace TestConsole
{
class Program
{
static void Main(string[] args)
{
Stopwatch sw = new Stopwatch();
sw.Start();
ArchiveCreator ss = new WinBaseZipCreator(@"d:\testzip1.zip");
ArchiveObj xx = ss.GetArchieve();
xx.AddFile(@"d:\TEST1.txt");
xx.AddFile(@"d:\TEST2.txt");
xx.SaveArchive();
sw.Stop();
Console.WriteLine(sw.Elapsed);
Thread.Sleep(5000);
sw.Restart();
ArchiveCreator sss = new IonicZipCreator(@"d:\testzip2.zip");
ArchiveObj xxx = sss.GetArchieve();
xxx.AddFile(@"d:\TEST1.txt");
xxx.AddFile(@"d:\TEST2.txt");
xxx.SaveArchive();
sw.Stop();
Console.WriteLine(sw.Elapsed);
Thread.Sleep(5000);
sw.Restart();
ArchiveCreator ssss = new ZipShellCreator(@"d:\testzip3.zip");
ArchiveObj xxxx = ssss.GetArchieve();
xxxx.AddFile(@"d:\TEST1.txt");
xxxx.AddFile(@"d:\TEST2.txt");
xxxx.SaveArchive();
sw.Stop();
Console.WriteLine(sw.Elapsed);
Console.ReadLine();
}
}
}