Skip to content
Snippets Groups Projects
Commit fc8d9260 authored by Paul Nitzke's avatar Paul Nitzke
Browse files

Add small profiling example

* We can use the Stopwatch class to time the execution of our program.
* This commit implements this experimentally for the partition to
  colored dot execution path.
* This is considered a work in progress and should NOT be merged into
  master.
* A proper implementation would likely involve some overseeing structure
  in ConversionManager for the execution methods to hook into and
  provide their timing
* The goal is to design this independent from the frontend so an
  interface to the frontend must also be provided.
parent bfdc604c
No related branches found
No related tags found
No related merge requests found
using SparseTransform.DataStructures; using SparseTransform.DataStructures;
using SparseTransform.Convert; using SparseTransform.Convert;
using System.Diagnostics;
namespace SparseTransform namespace SparseTransform
{ {
...@@ -29,19 +30,53 @@ namespace SparseTransform ...@@ -29,19 +30,53 @@ namespace SparseTransform
public static String Partition2ColoredDot(String MMMatrix, bool textColor = false) public static String Partition2ColoredDot(String MMMatrix, bool textColor = false)
{ {
MatrixMarketReader reader = new MatrixMarketReader(); MatrixMarketReader reader = new MatrixMarketReader();
Stopwatch inWatch = Stopwatch.StartNew();
IGraph graph = reader.ReadGraph(MMMatrix); IGraph graph = reader.ReadGraph(MMMatrix);
inWatch.Stop();
TimeSpan inTime = inWatch.Elapsed;
Colorer color = new Colorer(); Colorer color = new Colorer();
if (graph is AdjacencyGraph)
{
color.StarColor1((AdjacencyGraph) graph);
Stopwatch colWatch = Stopwatch.StartNew();
if (graph is AdjacencyGraph)
{
color.StarColor1((AdjacencyGraph)graph);
} }
else else
{
color.PartialD2Color((BipartiteGraph)graph); color.PartialD2Color((BipartiteGraph)graph);
}
colWatch.Stop();
TimeSpan colTime = colWatch.Elapsed;
ColoredDotWriter writer = new ColoredDotWriter(graph, textColor); ColoredDotWriter writer = new ColoredDotWriter(graph, textColor);
return writer.Write(graph);
Stopwatch outWatch = Stopwatch.StartNew();
String dotOutput = writer.Write(graph);
outWatch.Stop();
TimeSpan outTime = outWatch.Elapsed;
string inTimeOutput = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
inTime.Hours, inTime.Minutes, inTime.Seconds,
inTime.Milliseconds / 10);
string colTimeOutput = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
colTime.Hours, colTime.Minutes, colTime.Seconds,
colTime.Milliseconds / 10);
string outTimeOutput = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
outTime.Hours, outTime.Minutes, outTime.Seconds,
outTime.Milliseconds / 10);
Console.WriteLine($"Time elapsed in ConversionManager:\nIn-Transformation:\t{inTimeOutput}\nColoring:\t\t{colTimeOutput}\nOut-Transformation:\t{outTimeOutput}\n");
return dotOutput;
} }
/// <summary> /// <summary>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment