Created
January 29, 2013 03:40
-
-
Save SidShetye/4661615 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Application app = new Application(); | |
app.Run(); | |
} | |
} | |
public class Application | |
{ | |
public void Run() | |
{ | |
int samplesToCollect = 100; | |
string executable = "openssl"; | |
List<string> allArgs = new List<string>(); | |
allArgs.Add("q"); // just quit - to find invocation overhead | |
allArgs.Add("aes-256-gcm -in 10M-plain.bin -out /dev/null -k password.txt"); | |
allArgs.Add("aes-256-cbc -in 10M-plain.bin -out /dev/null -k password.txt"); | |
foreach (string arg in allArgs) | |
{ | |
double totalMs = 0; | |
for (int i = 0; i < samplesToCollect; i++) | |
{ | |
totalMs += RunCommandGetTime(executable, arg).TotalMilliseconds; | |
} | |
Console.WriteLine("'{0} {1}' took {2} milliseconds (avg)", executable, arg, totalMs / samplesToCollect); //avg | |
} | |
Console.ReadLine(); | |
} | |
private TimeSpan RunCommandGetTime(string exe, string args) | |
{ | |
Stopwatch sw = new Stopwatch(); | |
Process myProcess = new Process(); | |
myProcess.StartInfo.UseShellExecute = false; | |
myProcess.StartInfo.FileName = exe; | |
myProcess.StartInfo.Arguments = args; | |
myProcess.StartInfo.CreateNoWindow = false; // true; | |
myProcess.StartInfo.RedirectStandardOutput = true; | |
myProcess.StartInfo.RedirectStandardError = true; | |
sw.Start(); | |
myProcess.Start(); | |
myProcess.WaitForExit(); | |
sw.Stop(); | |
return sw.Elapsed; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment