format output slightly more nicely
This commit is contained in:
parent
88cea8be53
commit
640ae5aea5
29
Program.cs
29
Program.cs
|
|
@ -12,21 +12,30 @@ using System.Threading.Tasks;
|
||||||
using SkiaSharp;
|
using SkiaSharp;
|
||||||
|
|
||||||
int currentImageSize = 1024;
|
int currentImageSize = 1024;
|
||||||
(float[] result, double timeTakenSecondsEvaluate) = BenchmarkFunction(() =>
|
string combinedOutputString = string.Empty;
|
||||||
{
|
|
||||||
Instruction[] instructions = Parsing.Parse("Programs/prospero.vm");
|
|
||||||
return Interpreter.Evaluate(instructions, imageSize: currentImageSize);
|
|
||||||
});
|
|
||||||
|
|
||||||
Console.WriteLine($"Sharpero took: {timeTakenSecondsEvaluate} seconds to evaluate {currentImageSize}x{currentImageSize} image!");
|
(bool success, double totalTimeTakenSecondsOutput) = BenchmarkFunction(() =>
|
||||||
|
|
||||||
(bool success, double timeTakenSecondsOutput) = BenchmarkFunction(() =>
|
|
||||||
{
|
{
|
||||||
CreateOutputImage(currentImageSize, result, "prospero.jpg");
|
(float[] result, double timeTakenSecondsEvaluate) = BenchmarkFunction(() =>
|
||||||
|
{
|
||||||
|
Instruction[] instructions = Parsing.Parse("Programs/prospero.vm");
|
||||||
|
return Interpreter.Evaluate(instructions, imageSize: currentImageSize);
|
||||||
|
});
|
||||||
|
|
||||||
|
combinedOutputString += $" - took: {timeTakenSecondsEvaluate} seconds to evaluate the image!" + Environment.NewLine;
|
||||||
|
|
||||||
|
(bool success, double timeTakenSecondsOutput) = BenchmarkFunction(() =>
|
||||||
|
{
|
||||||
|
CreateOutputImage(currentImageSize, result, "prospero.jpg");
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
combinedOutputString += $" - took: {timeTakenSecondsOutput} seconds to write out image!" + Environment.NewLine;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
Console.WriteLine($"Sharpero took: {timeTakenSecondsOutput} seconds to write out {currentImageSize}x{currentImageSize} image!");
|
Console.Write($"Sharpero took: {totalTimeTakenSecondsOutput} seconds to evaluate {currentImageSize}x{currentImageSize} image!" + Environment.NewLine + combinedOutputString);
|
||||||
|
|
||||||
(T, double) BenchmarkFunction<T>(Func<T> benchmarkedFunction)
|
(T, double) BenchmarkFunction<T>(Func<T> benchmarkedFunction)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue