fixed
This commit is contained in:
@@ -10,8 +10,7 @@ namespace TMI_practicum
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
|
||||
//SweepLineEffAlgorithm.Solve(null);
|
||||
GetChartData();
|
||||
if (args.Length < 1)
|
||||
{
|
||||
Console.WriteLine("Please enter a file.");
|
||||
@@ -26,9 +25,11 @@ namespace TMI_practicum
|
||||
|
||||
var (algorithm, _, circles) = ParseFile(args[0]);
|
||||
|
||||
IEnumerable<Intersection> solved;
|
||||
|
||||
|
||||
Stopwatch stopwatch = new Stopwatch();
|
||||
IEnumerable<Intersection> solved;
|
||||
|
||||
stopwatch.Start();
|
||||
|
||||
switch (algorithm)
|
||||
@@ -45,12 +46,56 @@ namespace TMI_practicum
|
||||
default:
|
||||
throw new ArgumentException("Algorithm with id: " + algorithm + " is not defined!");
|
||||
}
|
||||
|
||||
|
||||
stopwatch.Stop();
|
||||
WriteOutput(solved, stopwatch.ElapsedMilliseconds);
|
||||
}
|
||||
|
||||
|
||||
private static List<Circle> CreateRandomCircles(double amount)
|
||||
{
|
||||
var circles = new List<Circle>();
|
||||
Random rnd = new Random();
|
||||
|
||||
for (int i = 0; i < amount; i++)
|
||||
{
|
||||
circles.Add(new Circle(Math.Round(rnd.NextDouble() * 1.0, 15), Math.Round(rnd.NextDouble() * 1.0, 15), Math.Round(rnd.NextDouble() * 0.01, 15)));
|
||||
}
|
||||
|
||||
return circles;
|
||||
}
|
||||
|
||||
private static void GetChartData()
|
||||
{
|
||||
|
||||
var stopwatch = new Stopwatch();
|
||||
|
||||
//warmup
|
||||
var circles = CreateRandomCircles(20);
|
||||
IEnumerable<Intersection> solved = SweepLineEffAlgorithm.Solve(circles);
|
||||
var times = new List<long>();
|
||||
|
||||
Console.WriteLine("size, time");
|
||||
|
||||
for (int s = 10; s < 100000; s *= 2)
|
||||
{
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
circles = CreateRandomCircles(s);
|
||||
|
||||
stopwatch.Restart();
|
||||
solved = SweepLineEffAlgorithm.Solve(circles);
|
||||
stopwatch.Stop();
|
||||
times.Add(stopwatch.ElapsedMilliseconds);
|
||||
}
|
||||
|
||||
Console.WriteLine("{0}, {1}", s, times.Average());
|
||||
times.Clear();
|
||||
}
|
||||
|
||||
stopwatch.Stop();
|
||||
}
|
||||
|
||||
private static (byte Algorithm, int NbCircles, IList<Circle> Circles) ParseFile(string path)
|
||||
{
|
||||
|
||||
|
Reference in New Issue
Block a user