added getchartdata
This commit is contained in:
@@ -25,7 +25,7 @@ namespace TMI_practicum
|
|||||||
Environment.Exit(1);
|
Environment.Exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.Length > 1) OutputFile = args[1];
|
if (args.Length > 1) _outputFile = args[1];
|
||||||
|
|
||||||
|
|
||||||
(byte algorithm, _, IList<Circle> circles) = ParseFile(inputFile);
|
(byte algorithm, _, IList<Circle> circles) = ParseFile(inputFile);
|
||||||
@@ -48,12 +48,12 @@ namespace TMI_practicum
|
|||||||
solved = SweepLineEffAlgorithm.Solve(circles);
|
solved = SweepLineEffAlgorithm.Solve(circles);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (File.Exists(OutputFile))
|
if (File.Exists(_outputFile))
|
||||||
{
|
{
|
||||||
File.Delete(OutputFile);
|
File.Delete(_outputFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
using (StreamWriter sw = File.CreateText(OutputFile))
|
using (StreamWriter sw = File.CreateText(_outputFile))
|
||||||
{
|
{
|
||||||
sw.WriteLine("Dit algoritme is niet ge ̈ımplementeerd.");
|
sw.WriteLine("Dit algoritme is niet ge ̈ımplementeerd.");
|
||||||
}
|
}
|
||||||
@@ -150,25 +150,47 @@ namespace TMI_practicum
|
|||||||
|
|
||||||
//warmup
|
//warmup
|
||||||
var circles = CreateRandomCircles(20);
|
var circles = CreateRandomCircles(20);
|
||||||
IEnumerable<Intersection> solved = SweepLineEffAlgorithm.Solve(circles);
|
|
||||||
var times = new List<long>();
|
SweepLineEffAlgorithm.Solve(circles);
|
||||||
|
SweepLineAlgorithm.Solve(circles);
|
||||||
|
SimpleAlgorithm.Solve(circles);
|
||||||
|
|
||||||
|
var times = new Dictionary<string, List<long>>();
|
||||||
|
times.Add("algo1", new List<long>());
|
||||||
|
times.Add("algo2", new List<long>());
|
||||||
|
times.Add("algo3", new List<long>());
|
||||||
|
|
||||||
Console.WriteLine("size, time");
|
Console.WriteLine("size,\t algo1,\t algo2,\t algo3");
|
||||||
|
|
||||||
for (int s = 10; s < 100000; s *= 2)
|
for (int s = 2; s < 300000; s *= 2)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 100; i++)
|
for (int i = 0; i < 100; i++)
|
||||||
{
|
{
|
||||||
circles = CreateRandomCircles(s);
|
circles = CreateRandomCircles(s);
|
||||||
|
|
||||||
|
if (s < 50000)
|
||||||
|
{
|
||||||
|
stopwatch.Restart();
|
||||||
|
SimpleAlgorithm.Solve(circles);
|
||||||
|
stopwatch.Stop();
|
||||||
|
times["algo1"].Add(stopwatch.ElapsedMilliseconds);
|
||||||
|
} else times["algo1"].Add(0);
|
||||||
|
|
||||||
stopwatch.Restart();
|
stopwatch.Restart();
|
||||||
solved = SweepLineEffAlgorithm.Solve(circles);
|
SweepLineAlgorithm.Solve(circles);
|
||||||
stopwatch.Stop();
|
stopwatch.Stop();
|
||||||
times.Add(stopwatch.ElapsedMilliseconds);
|
times["algo2"].Add(stopwatch.ElapsedMilliseconds);
|
||||||
|
|
||||||
|
stopwatch.Restart();
|
||||||
|
SweepLineEffAlgorithm.Solve(circles);
|
||||||
|
stopwatch.Stop();
|
||||||
|
times["algo3"].Add(stopwatch.ElapsedMilliseconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
Console.WriteLine("{0}, {1}", s, times.Average());
|
Console.WriteLine("{0},\t {1},\t {2},\t {3}", s, times["algo1"].Average(), times["algo2"].Average(), times["algo3"].Average());
|
||||||
times.Clear();
|
times["algo1"].Clear();
|
||||||
|
times["algo2"].Clear();
|
||||||
|
times["algo3"].Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
stopwatch.Stop();
|
stopwatch.Stop();
|
||||||
@@ -208,16 +230,16 @@ namespace TMI_practicum
|
|||||||
return (algorithm, nbCircles, circles);
|
return (algorithm, nbCircles, circles);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string OutputFile = "output.txt";
|
private static string _outputFile = "output.txt";
|
||||||
|
|
||||||
private static void WriteOutput(IEnumerable<Intersection> intersections, double time)
|
private static void WriteOutput(IEnumerable<Intersection> intersections, double time)
|
||||||
{
|
{
|
||||||
if (File.Exists(OutputFile))
|
if (File.Exists(_outputFile))
|
||||||
{
|
{
|
||||||
File.Delete(OutputFile);
|
File.Delete(_outputFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
using (StreamWriter sw = File.CreateText(OutputFile))
|
using (StreamWriter sw = File.CreateText(_outputFile))
|
||||||
{
|
{
|
||||||
foreach (Intersection intersection in intersections)
|
foreach (Intersection intersection in intersections)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user