Exemplo n.º 1
0
        private List<long> runFile(string file, IDynamicGraph alg, int resolution, int repeatCount)
        {
            InputFile graph = readFile(file);
            Stopwatch sw = new Stopwatch();
            List<List<long>> times = new List<List<long>>();
            List<List<long>> timesVector = new List<List<long>>();

            for (int i = 0; i < repeatCount; i++)
            {
                alg.ResetAll(graph.n);
                int skip = 0;
                times.Add(new List<long>());

                for (int n = 0; n < graph.n; n++)
                    alg.AddVertex();

                do
                {
                    sw.Start();
                    foreach(var edge in graph.edges.Skip(skip).Take(resolution))
                    {
                        alg.AddEdge(edge.from, edge.to);
                    }
                    sw.Stop();
                    times[i].Add(sw.ElapsedTicks);
                    sw.Reset();

                    skip += resolution;
                } while (skip < graph.edges.Count);                
            }

            var ret = Transpose(times).ConvertAll(item => ((long)item.Average()));

            return ret;
        }
Exemplo n.º 2
0
        private MinAvgMax RunFolderDynamicGraph(string folder, IDynamicGraph alg)
        {
            var values = new List<long>();
            var sw = new Stopwatch();

            foreach (var file in Directory.EnumerateFiles(folder))
            {
                var graph = readFile(file);
                alg.ResetAll(graph.n, graph.m);

                for(int i = 0; i < graph.n; i++)
                    alg.AddVertex();

                sw.Reset();

                //force gc               
                GC.Collect();
                GC.WaitForPendingFinalizers();
                GC.Collect();

                sw.Start();
                foreach (var edge in graph.edges)
                {
                    alg.AddEdge(edge.from, edge.to);                    
                }

                var top = alg.Topology();
                sw.Stop();
                values.Add(sw.ElapsedTicks);
            }

            return new MinAvgMax(values.Min(), (long)values.Average(), values.Max());
        }