Skip to content

Commit

Permalink
Merge branch 'mu-20241112-issue-1041-camera-mlkit-vision' of https://…
Browse files Browse the repository at this point in the history
…github.com/dotnet/android-libraries into mu-20241112-issue-1041-camera-mlkit-vision
  • Loading branch information
moljac committed Nov 14, 2024
2 parents 40f2fa0 + 8255b5b commit 287d013
Show file tree
Hide file tree
Showing 3 changed files with 138 additions and 0 deletions.
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

0 comments on commit 287d013

Please sign in to comment.