More performance tracking
This commit is contained in:
parent
0e7bd12c4f
commit
69ef560105
12
Program.cs
12
Program.cs
|
|
@ -160,7 +160,7 @@ class Program
|
||||||
static Tuple<bool,Dictionary<string,string>?> CheckDeps(List<string>? dependencies)
|
static Tuple<bool,Dictionary<string,string>?> CheckDeps(List<string>? dependencies)
|
||||||
{
|
{
|
||||||
bool success = true;
|
bool success = true;
|
||||||
|
Stopwatch timer = new();
|
||||||
if (! (dependencies?.Count() > 0)) // assume success as no dependencies
|
if (! (dependencies?.Count() > 0)) // assume success as no dependencies
|
||||||
{
|
{
|
||||||
return new Tuple<bool,Dictionary<string,string>?>(true,null);
|
return new Tuple<bool,Dictionary<string,string>?>(true,null);
|
||||||
|
|
@ -176,6 +176,7 @@ class Program
|
||||||
Log.Debug("Path is: {path}",path);
|
Log.Debug("Path is: {path}",path);
|
||||||
|
|
||||||
List<string> executables = new();
|
List<string> executables = new();
|
||||||
|
timer = Stopwatch.StartNew();
|
||||||
foreach (string dir in path)
|
foreach (string dir in path)
|
||||||
{
|
{
|
||||||
if (Directory.Exists(dir)) // Sometimes People fuck up their path variables and include directories that don't exist.
|
if (Directory.Exists(dir)) // Sometimes People fuck up their path variables and include directories that don't exist.
|
||||||
|
|
@ -183,7 +184,9 @@ class Program
|
||||||
executables.AddRange(GetAllFiles(dir));
|
executables.AddRange(GetAllFiles(dir));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
timer.Stop();
|
||||||
Log.Verbose("Executables are: {executables}",executables);
|
Log.Verbose("Executables are: {executables}",executables);
|
||||||
|
Log.Information("Got executables list in {timer:000}ms",timer.ElapsedMilliseconds);
|
||||||
|
|
||||||
// Do some regex magic to find an executable in the path.
|
// Do some regex magic to find an executable in the path.
|
||||||
Dictionary<string,string>? result = new();
|
Dictionary<string,string>? result = new();
|
||||||
|
|
@ -191,18 +194,21 @@ class Program
|
||||||
|
|
||||||
foreach (string dependency in dependencies)
|
foreach (string dependency in dependencies)
|
||||||
{
|
{
|
||||||
|
timer = Stopwatch.StartNew();
|
||||||
string regex = $"/(.*/)*{dependency}";
|
string regex = $"/(.*/)*{dependency}";
|
||||||
Regex expr = new Regex(regex,RegexOptions.Compiled);
|
Regex expr = new Regex(regex,RegexOptions.Compiled);
|
||||||
Log.Debug("Compiled regex: {expr}",expr);
|
Log.Debug("Compiled regex: {expr}",expr);
|
||||||
string? match = executables.Find( x => expr.IsMatch(x));
|
string? match = executables.Find( x => expr.IsMatch(x));
|
||||||
if (match is not null && match != "")
|
if (match is not null && match != "")
|
||||||
{
|
{
|
||||||
Log.Information("Dependency {dep} found at {path}",dependency,match);
|
timer.Stop();
|
||||||
|
Log.Information("Dependency {dep} found at {path} in {timer:000}ms",dependency,match,timer.ElapsedMilliseconds);
|
||||||
result.Add(dependency,match); // Create a dictionary of paths to found executables
|
result.Add(dependency,match); // Create a dictionary of paths to found executables
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log.Information("Dependency {dep} cannot be found",dependency);
|
timer.Stop();
|
||||||
|
Log.Information("Dependency {dep} cannot be found, search took {timer:000ms}",dependency,timer.ElapsedMilliseconds);
|
||||||
success = false;
|
success = false;
|
||||||
failures.Add(dependency,dependency);
|
failures.Add(dependency,dependency);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user