Dev Improvements #4
@@ -3,6 +3,7 @@
|
|||||||
// /media/omegaleo/Development/Library Dev/HelperLib
|
// /media/omegaleo/Development/Library Dev/HelperLib
|
||||||
|
|
||||||
using GameDevLibrary.Extensions;
|
using GameDevLibrary.Extensions;
|
||||||
|
using GameDevLibrary.Helpers;
|
||||||
using LibGit2Sharp;
|
using LibGit2Sharp;
|
||||||
using OmegaLeo.HelperLib.Git;
|
using OmegaLeo.HelperLib.Git;
|
||||||
using OmegaLeo.HelperLib.Git.Models;
|
using OmegaLeo.HelperLib.Git.Models;
|
||||||
@@ -17,51 +18,57 @@ if (repo.IsNullOrEmpty())
|
|||||||
|
|
||||||
var git = new GitClient(repo);
|
var git = new GitClient(repo);
|
||||||
|
|
||||||
var changes = git.GetChanges();
|
var result = BenchmarkUtility.Record(() =>
|
||||||
|
|
||||||
if (changes.FolderName.IsNotNullOrEmpty())
|
|
||||||
{
|
{
|
||||||
RecursiveOutput(new List<ChangeFolder>() { changes });
|
var changes = git.GetChanges();
|
||||||
|
|
||||||
var option = 99;
|
if (changes.FolderName.IsNotNullOrEmpty())
|
||||||
|
|
||||||
while (option != 0)
|
|
||||||
{
|
{
|
||||||
ShowOptions();
|
RecursiveOutput(new List<ChangeFolder>() { changes });
|
||||||
if (option != 99)
|
|
||||||
{
|
|
||||||
switch (option)
|
|
||||||
{
|
|
||||||
case 1:
|
|
||||||
Console.WriteLine("Write the commit message");
|
|
||||||
var msg = Console.ReadLine();
|
|
||||||
|
|
||||||
while (msg.IsNullOrEmpty())
|
var option = 99;
|
||||||
{
|
|
||||||
Console.WriteLine("Empty message detected, please write a commit message...");
|
while (option != 0)
|
||||||
msg = Console.ReadLine();
|
{
|
||||||
}
|
ShowOptions();
|
||||||
|
if (option != 99)
|
||||||
var signature = new Signature("Nuno 'Omega Leo' Diogo", "nunodiogo@omegaleo.pt", DateTimeOffset.Now);
|
{
|
||||||
git.Commit(msg, signature);
|
switch (option)
|
||||||
|
{
|
||||||
break;
|
case 1:
|
||||||
case 2:
|
Console.WriteLine("Write the commit message");
|
||||||
git.Push();
|
var msg = Console.ReadLine();
|
||||||
break;
|
|
||||||
default:
|
while (msg.IsNullOrEmpty())
|
||||||
Console.WriteLine("Invalid Option!");
|
{
|
||||||
break;
|
Console.WriteLine("Empty message detected, please write a commit message...");
|
||||||
|
msg = Console.ReadLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
var signature = new Signature("Nuno 'Omega Leo' Diogo", "nunodiogo@omegaleo.pt",
|
||||||
|
DateTimeOffset.Now);
|
||||||
|
git.Commit(msg, signature);
|
||||||
|
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
git.Push();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Console.WriteLine("Invalid Option!");
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int.TryParse(Console.ReadLine(), out option);
|
||||||
}
|
}
|
||||||
|
|
||||||
int.TryParse(Console.ReadLine(), out option);
|
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
else
|
{
|
||||||
{
|
Console.WriteLine("No changes found in specified repository");
|
||||||
Console.WriteLine("No changes found in specified repository");
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
|
Console.WriteLine($"Time for checking for changes: {result} ms");
|
||||||
|
|
||||||
Console.ReadLine();
|
Console.ReadLine();
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,70 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
|
namespace GameDevLibrary.Helpers
|
||||||
|
{
|
||||||
|
public class BenchmarkUtility
|
||||||
|
{
|
||||||
|
private static Dictionary<string, List<long>> _benchmarks = new Dictionary<string, List<long>>();
|
||||||
|
private static Dictionary<string, Stopwatch> _stopwatches = new Dictionary<string, Stopwatch>();
|
||||||
|
|
||||||
|
private static Stopwatch GetStopwatch(string key)
|
||||||
|
{
|
||||||
|
Stopwatch stopwatch = new Stopwatch();
|
||||||
|
|
||||||
|
if (_stopwatches.TryGetValue(key, out stopwatch))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
stopwatch = new Stopwatch();
|
||||||
|
_stopwatches.Add(key, stopwatch);
|
||||||
|
}
|
||||||
|
|
||||||
|
return stopwatch;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static long Record(Action actionToRecord)
|
||||||
|
{
|
||||||
|
var stopwatch = new Stopwatch();
|
||||||
|
stopwatch.Start();
|
||||||
|
|
||||||
|
actionToRecord.Invoke();
|
||||||
|
|
||||||
|
stopwatch.Stop();
|
||||||
|
return stopwatch.ElapsedMilliseconds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Start(string key)
|
||||||
|
{
|
||||||
|
GetStopwatch(key).Restart();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Stop(string key)
|
||||||
|
{
|
||||||
|
if (!_benchmarks.ContainsKey(key))
|
||||||
|
{
|
||||||
|
_benchmarks[key] = new List<long>();
|
||||||
|
}
|
||||||
|
|
||||||
|
GetStopwatch(key).Stop();
|
||||||
|
_benchmarks[key].Add(GetStopwatch(key).ElapsedMilliseconds);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<long> GetResults(string key)
|
||||||
|
{
|
||||||
|
return _benchmarks.ContainsKey(key) ? _benchmarks[key] : new List<long>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void ClearResults()
|
||||||
|
{
|
||||||
|
_benchmarks.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Dictionary<string, List<long>> GetAllResults()
|
||||||
|
{
|
||||||
|
return new Dictionary<string, List<long>>(_benchmarks);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user