Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manual updates 20241003 improvements data acquisition build timings measurements (20240211) #997

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@
#load "build/cake/validations.cake"
#load "build/cake/executive-order.cake"
#load "build/cake/clean.cake"
#load "build/cake/performance-timings.cake"

using System.Xml.Linq;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;


// The main configuration points
var TARGET = Argument ("t", Argument ("target", "Default"));
var CONFIGURATION = Argument ("c", Argument ("configuration", "Release"));
Expand Down
133 changes: 133 additions & 0 deletions build/cake/performance-timings.cake
Original file line number Diff line number Diff line change
@@ -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) );
}
);

3 changes: 3 additions & 0 deletions utilities.cake
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#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;

Expand All @@ -22,6 +24,7 @@ using Newtonsoft.Json.Linq;

using HolisticWare.Xamarin.Tools.ComponentGovernance;


var TARGET = Argument ("t", Argument ("target", "Default"));

string file_spell_errors = "./output/spell-errors.txt";
Expand Down