Skip to content

Instantly share code, notes, and snippets.

@mmennis
Created October 10, 2012 21:43
Show Gist options
  • Save mmennis/3868643 to your computer and use it in GitHub Desktop.
Save mmennis/3868643 to your computer and use it in GitHub Desktop.
Simepl events in WIndows for testing
using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string sSource = "dotNET sample app";
string sLog = "Application";
string sEvent = "Sample Event";
if (!EventLog.SourceExists(sSource))
{
EventLog.CreateEventSource(sSource, sLog);
}
EventLog myLog = new EventLog(sLog);
myLog.Clear();
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
for (int i = 0; i < 25000; i++)
{
EventLog.WriteEntry(sSource, sEvent);
EventLog.WriteEntry(sSource, sEvent, EventLogEntryType.Warning, 234);
EventLog.WriteEntry(sSource, sEvent, EventLogEntryType.Error, 123);
EventLog.WriteEntry(sSource, sEvent, EventLogEntryType.SuccessAudit, 555);
}
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10);
Console.WriteLine("Total runtime: " + elapsedTime);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment