-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
Release 1 (1.1.0) (#52)
- Loading branch information
Showing
135 changed files
with
9,250 additions
and
4,196 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
Px.Utils.TestingApp/Commands/DatabaseValidationBenchmark.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
using Px.Utils.Validation.DatabaseValidation; | ||
|
||
namespace Px.Utils.TestingApp.Commands | ||
{ | ||
internal sealed class DatabaseValidationBenchmark : Benchmark | ||
{ | ||
internal override string Help => "Validates a px path database."; | ||
|
||
internal override string Description => "Validates a px path database."; | ||
private static readonly string[] directoryFlags = ["-d", "-directory"]; | ||
|
||
private DatabaseValidator? validator; | ||
|
||
internal DatabaseValidationBenchmark() | ||
{ | ||
ParameterFlags.Add(directoryFlags); | ||
BenchmarkFunctions = [ValidationBenchmark]; | ||
BenchmarkFunctionsAsync = [ValidationBenchmarkAsync]; | ||
} | ||
|
||
protected override void SetRunParameters() | ||
{ | ||
foreach (string key in directoryFlags) | ||
{ | ||
if (Parameters.TryGetValue(key, out List<string>? value) && value.Count == 1) | ||
{ | ||
TestFilePath = value[0]; | ||
base.SetRunParameters(); | ||
return; | ||
} | ||
} | ||
|
||
throw new ArgumentException("Directory not found."); | ||
} | ||
|
||
protected override void StartInteractiveMode() | ||
{ | ||
base.StartInteractiveMode(); | ||
|
||
Console.WriteLine("Enter the path to the PX database root to benchmark"); | ||
string path = Console.ReadLine() ?? ""; | ||
|
||
while (!Directory.Exists(path)) | ||
{ | ||
Console.WriteLine("Path provided is not valid, please enter a path to a valid directory."); | ||
path = Console.ReadLine() ?? ""; | ||
} | ||
|
||
TestFilePath = path; | ||
} | ||
|
||
protected override void OneTimeBenchmarkSetup() | ||
{ | ||
base.OneTimeBenchmarkSetup(); | ||
|
||
validator = new(TestFilePath, new LocalFileSystem()); | ||
} | ||
|
||
private void ValidationBenchmark() | ||
{ | ||
if(validator is null) throw new InvalidOperationException("Validator not initialized."); | ||
validator.Validate(); | ||
} | ||
|
||
private async Task ValidationBenchmarkAsync() | ||
{ | ||
if(validator is null) throw new InvalidOperationException("Validator not initialized."); | ||
await validator.ValidateAsync(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.