From 4cdd906f3fff49a0504184f21ff23be9ffaf10df Mon Sep 17 00:00:00 2001 From: moljac Date: Sun, 11 Feb 2024 14:10:34 +0100 Subject: [PATCH 1/5] timings prepared - Stopwatch and Cake Task Duration --- build.cake | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/build.cake b/build.cake index 0bbaa7472..3d3b39202 100755 --- a/build.cake +++ b/build.cake @@ -22,6 +22,60 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; using CsvHelper; +System.Diagnostics.Stopwatch stopwatch; +List<(DateTime timestamp, string task, TimeSpan duration)> TimingDataStopwatch; +List<(DateTime timestamp, string task, TimeSpan duration)> TimingDataCake; + +Setup + ( + context => + { + // Executed BEFORE the first task. + stopwatch = new System.Diagnostics.Stopwatch(); + TimingDataStopwatch = new List<(DateTime timestampt, string task, TimeSpan duration)>(); + TimingDataCake = new List<(DateTime timestampt, string task, TimeSpan duration)>(); + + return; + } + ); + +Teardown + ( + context => + { + // Executed AFTER the last task. + foreach(var data in TimingDataStopwatch) + { + Information($" TimingDataStopwatch {data.timestamp},{data.task},{data.duration}"); + } + foreach(var data in TimingDataCake) + { + Information($" TimingDataCake {data.timestamp},{data.task},{data.duration}"); + } + } + ); + +TaskSetup + ( + context => + { + // Executed BEFORE the first task. + stopwatch.Start(); + + return; + } + ); + +TaskTeardown + ( + context => + { + stopwatch.Stop(); + TimingDataStopwatch.Add( (DateTime.Now, context.Task.Name, stopwatch.Elapsed) ); + TimingDataCake.Add( (DateTime.Now, context.Task.Name, context.Duration) ); + } + ); + // The main configuration points var TARGET = Argument ("t", Argument ("target", "Default")); var CONFIGURATION = Argument ("c", Argument ("configuration", "Release")); From b99db38a83a52ef789a0359e4c7d4da8cea23cc3 Mon Sep 17 00:00:00 2001 From: moljac Date: Mon, 9 Sep 2024 16:23:58 +0200 Subject: [PATCH 2/5] output fixed --- build.cake | 97 ++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 87 insertions(+), 10 deletions(-) diff --git a/build.cake b/build.cake index 140e49c8d..b7f159cbb 100755 --- a/build.cake +++ b/build.cake @@ -9,6 +9,8 @@ #addin nuget:?package=Cake.MonoApiTools&version=3.0.5 #addin nuget:?package=CsvHelper&version=31.0.3 #addin nuget:?package=SharpZipLib&version=1.4.2 +#addin nuget:?package=SharpZipLib&version=1.4.2 +#addin nuget:?package=ZString&version=2.6.0 // #addin nuget:?package=NuGet.Protocol&loaddependencies=true&version=5.6.0 // #addin nuget:?package=NuGet.Versioning&loaddependencies=true&version=5.6.0 @@ -23,6 +25,7 @@ using System.Xml.Linq; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using CsvHelper; +using Cysharp.Text; System.Diagnostics.Stopwatch stopwatch; List<(DateTime timestamp, string task, TimeSpan duration)> TimingDataStopwatch; @@ -34,8 +37,8 @@ Setup { // Executed BEFORE the first task. stopwatch = new System.Diagnostics.Stopwatch(); - TimingDataStopwatch = new List<(DateTime timestampt, string task, TimeSpan duration)>(); - TimingDataCake = new List<(DateTime timestampt, string task, TimeSpan duration)>(); + TimingDataStopwatch = new List<(DateTime timestamp, string task, TimeSpan duration)>(); + TimingDataCake = new List<(DateTime timestamp, string task, TimeSpan duration)>(); return; } @@ -46,14 +49,88 @@ Teardown context => { // Executed AFTER the last task. - foreach(var data in TimingDataStopwatch) - { - Information($" TimingDataStopwatch {data.timestamp},{data.task},{data.duration}"); - } - foreach(var data in TimingDataCake) - { - Information($" TimingDataCake {data.timestamp},{data.task},{data.duration}"); + + using(var sb1 = ZString.CreateStringBuilder()) + using(var sb2 = ZString.CreateStringBuilder()) + { + string line_1_1 = ZString.Format + ( + "{0,25},{1,20},{2,40},{3,25}", + "#TimingDataStopwatch", + "data.timestamp", + "data.task", + "data.duration" + ); + sb1.AppendLine(line_1_1); + foreach(var data in TimingDataStopwatch) + { + string line = ZString.Format + ( + "{0,25},{1,20},{2,40},{3,25}", + "#TimingDataStopwatch", + data.timestamp.ToString("yyyyMMdd-HHmmss.ff"), + data.task, + data.duration + ); + + Information(line); + sb1.AppendLine(line); + } + + string line_2_1 = ZString.Format + ( + "{0,25},{1,20},{2,40},{3,25}", + "#TimingDataCake", + "data.timestamp", + "data.task", + "data.duration" + ); + sb2.AppendLine(line_2_1); + foreach(var data in TimingDataCake) + { + string line = ZString.Format + ( + "{0,25},{1,20},{2,40},{3,25}", + "#TimingDataCake", + data.timestamp.ToString("yyyyMMdd-HHmmss.ff"), + data.task, + data.duration + ); + + Information(line); + sb2.AppendLine(line); + } + + + EnsureDirectoryExists("./output/timing-data/"); + string timestamp = DateTime.Now.ToString("yyyyMMdd-HHmmss"); + string filename = context.GetCallerInfo().SourceFilePath.GetFilename().ToString(); + + System.IO.File.WriteAllText + ( + $"./output/timing-data/{filename}.stopwatch.{timestamp}.csv", + sb1.ToString() + ); + System.IO.File.WriteAllText + ( + $"./output/timing-data/{filename}.cake-timer.{timestamp}.csv", + sb2.ToString() + ); + + EnsureDirectoryExists($"./data/timings/{timestamp}"); + System.IO.File.WriteAllText + ( + $"./data/timings/{timestamp}/{filename}.stopwatch.csv", + sb1.ToString() + ); + System.IO.File.WriteAllText + ( + $"./data/timings/{timestamp}/{filename}.cake-timer.csv", + sb2.ToString() + ); } + + return; } ); @@ -61,7 +138,7 @@ TaskSetup ( context => { - // Executed BEFORE the first task. + // Executed BEFORE the each task. stopwatch.Start(); return; From 95f12be4591a8be1774f5a3dbda36dd076e1a1ae Mon Sep 17 00:00:00 2001 From: moljac Date: Mon, 9 Sep 2024 16:24:09 +0200 Subject: [PATCH 3/5] output fixed --- utilities.cake | 131 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 131 insertions(+) diff --git a/utilities.cake b/utilities.cake index 284f7eef7..9c57fafaa 100644 --- a/utilities.cake +++ b/utilities.cake @@ -8,6 +8,7 @@ #addin nuget:?package=Newtonsoft.Json&version=13.0.3 #addin nuget:?package=Cake.FileHelpers&version=7.0.0 #addin nuget:?package=Mono.Cecil&version=0.11.5 +#addin nuget:?package=ZString&version=2.6.0 #addin nuget:?package=HolisticWare.Xamarin.Tools.ComponentGovernance&version=0.0.1.4 #addin nuget:?package=HolisticWare.Core.Net.HTTP&version=0.0.4 @@ -19,9 +20,139 @@ using System.Collections.Concurrent; using Mono.Cecil; using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using Cysharp.Text; using HolisticWare.Xamarin.Tools.ComponentGovernance; +System.Diagnostics.Stopwatch stopwatch; +List<(DateTime timestamp, string task, TimeSpan duration)> TimingDataStopwatch; +List<(DateTime timestamp, string task, TimeSpan duration)> TimingDataCake; + +Setup + ( + context => + { + // Executed BEFORE the first task. + stopwatch = new System.Diagnostics.Stopwatch(); + TimingDataStopwatch = new List<(DateTime timestamp, string task, TimeSpan duration)>(); + TimingDataCake = new List<(DateTime timestamp, string task, TimeSpan duration)>(); + + return; + } + ); + +Teardown + ( + context => + { + // Executed AFTER the last task. + + using(var sb1 = ZString.CreateStringBuilder()) + using(var sb2 = ZString.CreateStringBuilder()) + { + string line_1_1 = ZString.Format + ( + "{0,25},{1,20},{2,40},{3,25}", + "#TimingDataStopwatch", + "data.timestamp", + "data.task", + "data.duration" + ); + sb1.AppendLine(line_1_1); + foreach(var data in TimingDataStopwatch) + { + string line = ZString.Format + ( + "{0,25},{1,20},{2,40},{3,25}", + "#TimingDataStopwatch", + data.timestamp.ToString("yyyyMMdd-HHmmss.FF"), + data.task, + data.duration + ); + + Information(line); + sb1.AppendLine(line); + } + + string line_2_1 = ZString.Format + ( + "{0,25},{1,20},{2,40},{3,25}", + "#TimingDataCake", + "data.timestamp", + "data.task", + "data.duration" + ); + sb2.AppendLine(line_2_1); + foreach(var data in TimingDataCake) + { + string line = ZString.Format + ( + "{0,25},{1,20},{2,40},{3,25}", + "#TimingDataCake", + data.timestamp.ToString("yyyyMMdd-HHmmss.FF"), + data.task, + data.duration + ); + + Information(line); + sb2.AppendLine(line); + } + + + EnsureDirectoryExists("./output/timing-data/"); + string timestamp = DateTime.Now.ToString("yyyyMMdd-HHmmss"); + string filename = context.GetCallerInfo().SourceFilePath.GetFilename().ToString(); + + System.IO.File.WriteAllText + ( + $"./output/timing-data/{filename}.stopwatch.{timestamp}.csv", + sb1.ToString() + ); + System.IO.File.WriteAllText + ( + $"./output/timing-data/{filename}.cake-timer.{timestamp}.csv", + sb2.ToString() + ); + + EnsureDirectoryExists($"./data/timings/{timestamp}"); + System.IO.File.WriteAllText + ( + $"./data/timings/{timestamp}/{filename}.stopwatch.csv", + sb1.ToString() + ); + System.IO.File.WriteAllText + ( + $"./data/timings/{timestamp}/{filename}.cake-timer.csv", + sb2.ToString() + ); + } + + return; + } + ); + +TaskSetup + ( + context => + { + // Executed BEFORE the each task. + stopwatch.Start(); + + return; + } + ); + +TaskTeardown + ( + context => + { + stopwatch.Stop(); + TimingDataStopwatch.Add( (DateTime.Now, context.Task.Name, stopwatch.Elapsed) ); + TimingDataCake.Add( (DateTime.Now, context.Task.Name, context.Duration) ); + } + ); + + var TARGET = Argument ("t", Argument ("target", "Default")); string file_spell_errors = "./output/spell-errors.txt"; From 43641afe10bb3de0f8e4eb6cd223048b43245128 Mon Sep 17 00:00:00 2001 From: moljac Date: Wed, 9 Oct 2024 08:49:02 +0200 Subject: [PATCH 4/5] Create performance-timings.cake --- build/cake/performance-timings.cake | 133 ++++++++++++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 build/cake/performance-timings.cake diff --git a/build/cake/performance-timings.cake b/build/cake/performance-timings.cake new file mode 100644 index 000000000..4fb70b744 --- /dev/null +++ b/build/cake/performance-timings.cake @@ -0,0 +1,133 @@ +#addin nuget:?package=ZString&version=2.6.0 +#addin nuget:?package=ZString&version=2.6.0 + +using Cysharp.Text; + +System.Diagnostics.Stopwatch stopwatch; +List<(DateTime timestamp, string task, TimeSpan duration)> TimingDataStopwatch; +List<(DateTime timestamp, string task, TimeSpan duration)> TimingDataCake; + +Setup + ( + context => + { + // Executed BEFORE the first task. + stopwatch = new System.Diagnostics.Stopwatch(); + TimingDataStopwatch = new List<(DateTime timestamp, string task, TimeSpan duration)>(); + TimingDataCake = new List<(DateTime timestamp, string task, TimeSpan duration)>(); + + return; + } + ); + +Teardown + ( + context => + { + // Executed AFTER the last task. + + using(var sb1 = ZString.CreateStringBuilder()) + using(var sb2 = ZString.CreateStringBuilder()) + { + string line_1_1 = ZString.Format + ( + "{0,25},{1,20},{2,40},{3,25}", + "#TimingDataStopwatch", + "data.timestamp", + "data.task", + "data.duration" + ); + sb1.AppendLine(line_1_1); + foreach(var data in TimingDataStopwatch) + { + string line = ZString.Format + ( + "{0,25},{1,20},{2,40},{3,25}", + "#TimingDataStopwatch", + data.timestamp.ToString("yyyyMMdd-HHmmss.FF"), + data.task, + data.duration + ); + + Information(line); + sb1.AppendLine(line); + } + + string line_2_1 = ZString.Format + ( + "{0,25},{1,20},{2,40},{3,25}", + "#TimingDataCake", + "data.timestamp", + "data.task", + "data.duration" + ); + sb2.AppendLine(line_2_1); + foreach(var data in TimingDataCake) + { + string line = ZString.Format + ( + "{0,25},{1,20},{2,40},{3,25}", + "#TimingDataCake", + data.timestamp.ToString("yyyyMMdd-HHmmss.FF"), + data.task, + data.duration + ); + + Information(line); + sb2.AppendLine(line); + } + + + EnsureDirectoryExists("./output/timing-data/"); + string timestamp = DateTime.Now.ToString("yyyyMMdd-HHmmss"); + string filename = context.GetCallerInfo().SourceFilePath.GetFilename().ToString(); + + System.IO.File.WriteAllText + ( + $"./output/timing-data/{filename}.stopwatch.{timestamp}.csv", + sb1.ToString() + ); + System.IO.File.WriteAllText + ( + $"./output/timing-data/{filename}.cake-timer.{timestamp}.csv", + sb2.ToString() + ); + + EnsureDirectoryExists($"./data/timings/{timestamp}"); + System.IO.File.WriteAllText + ( + $"./data/timings/{timestamp}/{filename}.stopwatch.csv", + sb1.ToString() + ); + System.IO.File.WriteAllText + ( + $"./data/timings/{timestamp}/{filename}.cake-timer.csv", + sb2.ToString() + ); + } + + return; + } + ); + +TaskSetup + ( + context => + { + // Executed BEFORE the each task. + stopwatch.Start(); + + return; + } + ); + +TaskTeardown + ( + context => + { + stopwatch.Stop(); + TimingDataStopwatch.Add( (DateTime.Now, context.Task.Name, stopwatch.Elapsed) ); + TimingDataCake.Add( (DateTime.Now, context.Task.Name, context.Duration) ); + } + ); + From 7bd17702937d76deb5b4f87bfaeae3cbb5615a50 Mon Sep 17 00:00:00 2001 From: moljac Date: Wed, 9 Oct 2024 08:49:27 +0200 Subject: [PATCH 5/5] refactored to new cake file --- build.cake | 131 +----------------------------------------------- utilities.cake | 132 +------------------------------------------------ 2 files changed, 3 insertions(+), 260 deletions(-) diff --git a/build.cake b/build.cake index 416de0cf2..3f1e5ae72 100755 --- a/build.cake +++ b/build.cake @@ -9,8 +9,6 @@ #addin nuget:?package=Cake.MonoApiTools&version=3.0.5 #addin nuget:?package=CsvHelper&version=31.0.3 #addin nuget:?package=SharpZipLib&version=1.4.2 -#addin nuget:?package=SharpZipLib&version=1.4.2 -#addin nuget:?package=ZString&version=2.6.0 // #addin nuget:?package=NuGet.Protocol&loaddependencies=true&version=5.6.0 // #addin nuget:?package=NuGet.Versioning&loaddependencies=true&version=5.6.0 @@ -19,6 +17,7 @@ #load "build/cake/update-config.cake" #load "build/cake/tests.cake" #load "build/cake/gps-parameters.cake" +#load "build/cake/performance-timings.cake" using System.Text.RegularExpressions; using System.Xml; @@ -26,136 +25,8 @@ using System.Xml.Linq; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using CsvHelper; -using Cysharp.Text; - -System.Diagnostics.Stopwatch stopwatch; -List<(DateTime timestamp, string task, TimeSpan duration)> TimingDataStopwatch; -List<(DateTime timestamp, string task, TimeSpan duration)> TimingDataCake; - -Setup - ( - context => - { - // Executed BEFORE the first task. - stopwatch = new System.Diagnostics.Stopwatch(); - TimingDataStopwatch = new List<(DateTime timestamp, string task, TimeSpan duration)>(); - TimingDataCake = new List<(DateTime timestamp, string task, TimeSpan duration)>(); - - return; - } - ); - -Teardown - ( - context => - { - // Executed AFTER the last task. - - using(var sb1 = ZString.CreateStringBuilder()) - using(var sb2 = ZString.CreateStringBuilder()) - { - string line_1_1 = ZString.Format - ( - "{0,25},{1,20},{2,40},{3,25}", - "#TimingDataStopwatch", - "data.timestamp", - "data.task", - "data.duration" - ); - sb1.AppendLine(line_1_1); - foreach(var data in TimingDataStopwatch) - { - string line = ZString.Format - ( - "{0,25},{1,20},{2,40},{3,25}", - "#TimingDataStopwatch", - data.timestamp.ToString("yyyyMMdd-HHmmss.ff"), - data.task, - data.duration - ); - - Information(line); - sb1.AppendLine(line); - } - - string line_2_1 = ZString.Format - ( - "{0,25},{1,20},{2,40},{3,25}", - "#TimingDataCake", - "data.timestamp", - "data.task", - "data.duration" - ); - sb2.AppendLine(line_2_1); - foreach(var data in TimingDataCake) - { - string line = ZString.Format - ( - "{0,25},{1,20},{2,40},{3,25}", - "#TimingDataCake", - data.timestamp.ToString("yyyyMMdd-HHmmss.ff"), - data.task, - data.duration - ); - - Information(line); - sb2.AppendLine(line); - } - EnsureDirectoryExists("./output/timing-data/"); - string timestamp = DateTime.Now.ToString("yyyyMMdd-HHmmss"); - string filename = context.GetCallerInfo().SourceFilePath.GetFilename().ToString(); - - System.IO.File.WriteAllText - ( - $"./output/timing-data/{filename}.stopwatch.{timestamp}.csv", - sb1.ToString() - ); - System.IO.File.WriteAllText - ( - $"./output/timing-data/{filename}.cake-timer.{timestamp}.csv", - sb2.ToString() - ); - - EnsureDirectoryExists($"./data/timings/{timestamp}"); - System.IO.File.WriteAllText - ( - $"./data/timings/{timestamp}/{filename}.stopwatch.csv", - sb1.ToString() - ); - System.IO.File.WriteAllText - ( - $"./data/timings/{timestamp}/{filename}.cake-timer.csv", - sb2.ToString() - ); - } - - return; - } - ); - -TaskSetup - ( - context => - { - // Executed BEFORE the each task. - stopwatch.Start(); - - return; - } - ); - -TaskTeardown - ( - context => - { - stopwatch.Stop(); - TimingDataStopwatch.Add( (DateTime.Now, context.Task.Name, stopwatch.Elapsed) ); - TimingDataCake.Add( (DateTime.Now, context.Task.Name, context.Duration) ); - } - ); - // The main configuration points var TARGET = Argument ("t", Argument ("target", "Default")); var CONFIGURATION = Argument ("c", Argument ("configuration", "Release")); diff --git a/utilities.cake b/utilities.cake index c7bc507f3..98c8c79ac 100644 --- a/utilities.cake +++ b/utilities.cake @@ -8,150 +8,22 @@ #addin nuget:?package=Newtonsoft.Json&version=13.0.3 #addin nuget:?package=Cake.FileHelpers&version=7.0.0 #addin nuget:?package=Mono.Cecil&version=0.11.5 -#addin nuget:?package=ZString&version=2.6.0 #addin nuget:?package=HolisticWare.Xamarin.Tools.ComponentGovernance&version=0.0.1.4 #addin nuget:?package=HolisticWare.Core.Net.HTTP&version=0.0.4 #addin nuget:?package=HolisticWare.Core.IO&version=0.0.4 +#load "build/cake/performance-timings.cake" + using System.Collections.Generic; using System.Collections.Concurrent; using Mono.Cecil; using Newtonsoft.Json; using Newtonsoft.Json.Linq; -using Cysharp.Text; using HolisticWare.Xamarin.Tools.ComponentGovernance; -System.Diagnostics.Stopwatch stopwatch; -List<(DateTime timestamp, string task, TimeSpan duration)> TimingDataStopwatch; -List<(DateTime timestamp, string task, TimeSpan duration)> TimingDataCake; - -Setup - ( - context => - { - // Executed BEFORE the first task. - stopwatch = new System.Diagnostics.Stopwatch(); - TimingDataStopwatch = new List<(DateTime timestamp, string task, TimeSpan duration)>(); - TimingDataCake = new List<(DateTime timestamp, string task, TimeSpan duration)>(); - - return; - } - ); - -Teardown - ( - context => - { - // Executed AFTER the last task. - - using(var sb1 = ZString.CreateStringBuilder()) - using(var sb2 = ZString.CreateStringBuilder()) - { - string line_1_1 = ZString.Format - ( - "{0,25},{1,20},{2,40},{3,25}", - "#TimingDataStopwatch", - "data.timestamp", - "data.task", - "data.duration" - ); - sb1.AppendLine(line_1_1); - foreach(var data in TimingDataStopwatch) - { - string line = ZString.Format - ( - "{0,25},{1,20},{2,40},{3,25}", - "#TimingDataStopwatch", - data.timestamp.ToString("yyyyMMdd-HHmmss.FF"), - data.task, - data.duration - ); - - Information(line); - sb1.AppendLine(line); - } - - string line_2_1 = ZString.Format - ( - "{0,25},{1,20},{2,40},{3,25}", - "#TimingDataCake", - "data.timestamp", - "data.task", - "data.duration" - ); - sb2.AppendLine(line_2_1); - foreach(var data in TimingDataCake) - { - string line = ZString.Format - ( - "{0,25},{1,20},{2,40},{3,25}", - "#TimingDataCake", - data.timestamp.ToString("yyyyMMdd-HHmmss.FF"), - data.task, - data.duration - ); - - Information(line); - sb2.AppendLine(line); - } - - - EnsureDirectoryExists("./output/timing-data/"); - string timestamp = DateTime.Now.ToString("yyyyMMdd-HHmmss"); - string filename = context.GetCallerInfo().SourceFilePath.GetFilename().ToString(); - - System.IO.File.WriteAllText - ( - $"./output/timing-data/{filename}.stopwatch.{timestamp}.csv", - sb1.ToString() - ); - System.IO.File.WriteAllText - ( - $"./output/timing-data/{filename}.cake-timer.{timestamp}.csv", - sb2.ToString() - ); - - EnsureDirectoryExists($"./data/timings/{timestamp}"); - System.IO.File.WriteAllText - ( - $"./data/timings/{timestamp}/{filename}.stopwatch.csv", - sb1.ToString() - ); - System.IO.File.WriteAllText - ( - $"./data/timings/{timestamp}/{filename}.cake-timer.csv", - sb2.ToString() - ); - } - - return; - } - ); - -TaskSetup - ( - context => - { - // Executed BEFORE the each task. - stopwatch.Start(); - - return; - } - ); - -TaskTeardown - ( - context => - { - stopwatch.Stop(); - TimingDataStopwatch.Add( (DateTime.Now, context.Task.Name, stopwatch.Elapsed) ); - TimingDataCake.Add( (DateTime.Now, context.Task.Name, context.Duration) ); - } - ); - var TARGET = Argument ("t", Argument ("target", "Default"));