Esempio n. 1
0
        public static void Main(string[] args)
        {
            var r       = new Random();
            var watch   = new Stopwatch();
            var times   = new long[MAX_N, SAMPLES];
            var fortune = new FortunesAlgorithm();

            var output = new PoolLinkedList <VEdge>();

            for (var point = 1; point *INC <= MAX_N; point++)
            {
                var numPoints = point * INC;
                Console.WriteLine($"Running for n = {numPoints}");
                for (var sample = 1; sample <= SAMPLES; sample++)
                {
                    Console.WriteLine($"\tRunning sample {sample}");
                    watch.Reset();
                    var points = GenPoints(numPoints, r);
                    watch.Start();
                    fortune.Run(points, output, 0, 0, WIDTH, HEIGHT);
                    watch.Stop();
                    output.Clear((edge) =>
                    {
                        if (edge.Neighbor != null)
                        {
                            ObjectPool <VEdge> .Recycle(edge.Neighbor);
                        }
                        ObjectPool <VEdge> .Recycle(edge);
                    });
                    times[point - 1, sample - 1] = watch.ElapsedMilliseconds;
                }
            }

            var outFile   = File.CreateText("timings.csv");
            var excelFile = File.CreateText("excelTimings.csv");

            outFile.Write("N, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10" + Environment.NewLine);
            excelFile.Write("N, T (ms)" + Environment.NewLine);
            for (var i = 1; i *INC <= MAX_N; i++)
            {
                var s = i * INC + ", ";
                for (var j = 0; j < SAMPLES - 1; j++)
                {
                    s += times[i - 1, j] + ", ";
                }
                s += times[i - 1, SAMPLES - 1] + Environment.NewLine;
                outFile.Write(s);

                for (var j = 1; j <= SAMPLES; j++)
                {
                    excelFile.Write(i * INC + ", " + times[i - 1, j - 1] + Environment.NewLine);
                }
            }
            outFile.Dispose();
            excelFile.Dispose();
        }
Esempio n. 2
0
 private void ClearPoints()
 {
     foreach (var point in points)
     {
         ObjectPool <FortuneSite> .Recycle(point);
     }
     points.Clear();
     edges.Clear(RecycleEdge);
     delaunay.Clear();
 }