From cc13fa3b0dfa3fd06fe373503dbefbe37a24ac5d Mon Sep 17 00:00:00 2001 From: Delofon Date: Tue, 26 Jul 2022 19:31:44 +0300 Subject: [PATCH] Added clock to measure encoding/decoding time --- QOIDecoder/DecoderProgram.cs | 11 +++++++++++ QOIEncoder/EncoderProgram.cs | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/QOIDecoder/DecoderProgram.cs b/QOIDecoder/DecoderProgram.cs index 3940ab5..c617c56 100644 --- a/QOIDecoder/DecoderProgram.cs +++ b/QOIDecoder/DecoderProgram.cs @@ -11,9 +11,13 @@ namespace QOIDecoder class DecoderProgram { static bool verbose = false; + static DateTime t1; static void Main(string[] args) { + AppDomain.CurrentDomain.ProcessExit += ProcessExitMethod; + t1 = DateTime.UtcNow; + if (args.Length == 0) { PrintUsage(); @@ -211,6 +215,13 @@ static void Main(string[] args) static void Verbose(string str) { if (verbose) Console.WriteLine(str); } + static void ProcessExitMethod(object sender, EventArgs args) + { + DateTime t2 = DateTime.UtcNow; + TimeSpan time = t2 - t1; + Console.WriteLine($"Finished in {time.TotalMilliseconds} ms."); + } + static void PrintUsage() { Console.WriteLine("Usage: qoidecode [options] \nOptions:\n-h Print usage and exit.\n-v Verbose logging."); diff --git a/QOIEncoder/EncoderProgram.cs b/QOIEncoder/EncoderProgram.cs index f04a3b1..ccccd1d 100644 --- a/QOIEncoder/EncoderProgram.cs +++ b/QOIEncoder/EncoderProgram.cs @@ -12,9 +12,13 @@ namespace QOIEncoder class EncoderProgram { static bool verbose = false; + static DateTime t1; static void Main(string[] args) { + AppDomain.CurrentDomain.ProcessExit += ProcessExitMethod; + t1 = DateTime.UtcNow; + if (args.Length == 0) { PrintUsage(); @@ -197,6 +201,13 @@ static void Main(string[] args) static void Verbose(string str) { if (verbose) Console.WriteLine(str); } + static void ProcessExitMethod(object sender, EventArgs args) + { + DateTime t2 = DateTime.UtcNow; + TimeSpan time = t2 - t1; + Console.WriteLine($"Finished in {time.TotalMilliseconds} ms."); + } + static void PrintUsage() { Console.WriteLine("Usage: qoiencode [options] \nOptions:\n-h Print usage and exit.\n-v Verbose logging.");