コード例 #1
0
        public void AnalyzeResults0()
        {
            string folder = @"C:\Users\City-admin\Desktop\experiment\jialun\";
            Dictionary <int, DoubleStatistics> dict = new Dictionary <int, DoubleStatistics>();

            foreach (var file in Directory.GetFiles(folder))
            {
                var res        = new TopicStreamResult(file);
                var copyFactor = res.CopyFactor;
                var time       = res.OverallTime / 1000;
                if (!dict.ContainsKey(copyFactor))
                {
                    dict.Add(copyFactor, new DoubleStatistics());
                }
                dict[copyFactor].AddNumber(time);
            }

            foreach (var kvp in dict.OrderBy(kvp => kvp.Key))
            {
                Console.Write(kvp.Key + ", ");
            }
            Console.WriteLine();
            foreach (var kvp in dict.OrderBy(kvp => kvp.Key))
            {
                Console.Write(kvp.Value.GetAverage() + ", ");
            }
            Console.WriteLine();
            foreach (var kvp in dict.OrderBy(kvp => kvp.Key))
            {
                Console.Write(kvp.Value.GetStd() + ", ");
            }
        }
コード例 #2
0
        public void AnalyzeResultsTopicNumber()
        {
            bool isAddVisTime = true;
            var  folders      = new []
            {
                @"D:\Project\StreamingRoseRiver\ScalabilityExperiment\Results\RunTimeExperiment-13579\",
                @"D:\Project\StreamingRoseRiver\ScalabilityExperiment\Results\RunTimeExperiment-111315\",
                //@"D:\Project\StreamingRoseRiver\ScalabilityExperiment\Results\RunTimeExperiment-17\"
            };
            //Dictionary<int, Dictionary<int, DoubleStatistics[]>> statDictionary = new Dictionary<int, Dictionary<int, DoubleStatistics[]>>();
            Dictionary <Tuple <int, int, int>, DoubleStatistics[]> statDictionary = new Dictionary <Tuple <int, int, int>, DoubleStatistics[]>();

            HashSet <int> copyFactors = new HashSet <int>();
            HashSet <int> focusCounts = new HashSet <int>();
            HashSet <int> treeCounts  = new HashSet <int>();

            foreach (var folder in folders)
            {
                foreach (var file in Directory.GetFiles(folder))
                {
                    var result = new TopicStreamResult(file);

                    var key = Tuple.Create(result.CopyFactor, result.FocusCount, result.TreeCount);
                    DoubleStatistics[] value;
                    if (!statDictionary.TryGetValue(key, out value))
                    {
                        value = Util.GetInitializedArray(4, () => new DoubleStatistics()); //new DoubleStatistics[4];
                        statDictionary.Add(key, value);
                    }
                    value[0].AddNumber(result.TreeCutTime + (isAddVisTime ? result.VisTime : 0.0));
                    value[1].AddNumber(result.DAGTime);
                    value[2].AddNumber(result.SedimentationTime);
                    value[3].AddNumber(result.TreeCutTime + (isAddVisTime ? result.VisTime : 0.0) + result.DAGTime + result.SedimentationTime);

                    copyFactors.Add(result.CopyFactor);
                    focusCounts.Add(result.FocusCount);
                    treeCounts.Add(result.TreeCount);
                }
            }

            if (treeCounts.Count != 2)
            {
                throw new ArgumentException();
            }
            var copyFactorList = new List <int>(copyFactors);

            copyFactorList.Sort();
            var focusCountList = new List <int>(focusCounts);

            focusCountList.Sort();
            var minTreeCnt = treeCounts.Min();
            var maxTreeCnt = treeCounts.Max();

            double[][,] matrices = Util.GetInitializedArray(4,
                                                            () => new double[copyFactorList.Count, focusCountList.Count]);
            int copyFactorIndex = 0;

            foreach (var copyFactor in copyFactorList)
            {
                int focusCountIndex = 0;
                foreach (var focusCount in focusCountList)
                {
                    var tuple1 = Tuple.Create(copyFactor, focusCount, minTreeCnt);
                    var tuple2 = Tuple.Create(copyFactor, focusCount, maxTreeCnt);
                    var stats1 = statDictionary[tuple1];
                    var stats2 = statDictionary[tuple2];

                    //var treeCutTime = (stats2[0].GetAverage() - stats1[0].GetAverage())/(maxTreeCnt - minTreeCnt);
                    //var dagTime = (stats2[1].GetAverage() - stats1[1].GetAverage()) / (maxTreeCnt - minTreeCnt);
                    //var sedimentationTime = (stats2[2].GetAverage() - stats1[2].GetAverage()) / (maxTreeCnt - minTreeCnt);
                    //var totalTime = treeCutTime + dagTime + sedimentationTime;
                    for (int i = 0; i < 4; i++)
                    {
                        matrices[i][copyFactorIndex, focusCountIndex] = (stats2[i].GetAverage() - stats1[i].GetAverage()) / (maxTreeCnt - minTreeCnt);
                    }

                    focusCountIndex++;
                }
                copyFactorIndex++;
            }

            for (int i = 0; i < 4; i++)
            {
                Console.Write("[");
                for (int j = 0; j < copyFactorList.Count; j++)
                {
                    for (int k = 0; k < focusCountList.Count; k++)
                    {
                        Console.Write(matrices[i][j, k] + (k == focusCountList.Count - 1 ? ";" : ","));
                    }
                    if (j == copyFactorList.Count - 1)
                    {
                        Console.WriteLine("]/1000;");
                    }
                    else
                    {
                        Console.WriteLine("...");
                    }
                }
                Console.WriteLine();
            }
        }
コード例 #3
0
        public void AnalyzeResultsTreeCounts()
        {
            bool isAddVisTime = true;
            var  folders      = new[]
            {
                @"D:\Project\StreamingRoseRiver\ScalabilityExperiment\Results\RunTimeExperiment-TreeCountExp2\",
                //@"D:\Project\StreamingRoseRiver\ScalabilityExperiment\Results\RunTimeExperiment-supp\",
                //@"D:\Project\StreamingRoseRiver\ScalabilityExperiment\Results\RunTimeExperiment-TreeCount\",
                //@"D:\Project\StreamingRoseRiver\ScalabilityExperiment\Results\RunTimeExperiment-TreeCountStart19\",
                //@"D:\Project\StreamingRoseRiver\ScalabilityExperiment\Results\RunTimeExperiment-treeCount21End\",
            };
            //Dictionary<int, Dictionary<int, DoubleStatistics[]>> statDictionary = new Dictionary<int, Dictionary<int, DoubleStatistics[]>>();
            Dictionary <Tuple <int, int, int>, Dictionary <int, double> > statDictionary =
                new Dictionary <Tuple <int, int, int>, Dictionary <int, double> >();

            HashSet <int> copyFactors = new HashSet <int>();
            HashSet <int> focusCounts = new HashSet <int>();
            HashSet <int> treeCounts  = new HashSet <int>();
            HashSet <int> focusSeeds  = new HashSet <int>();

            foreach (var folder in folders)
            {
                foreach (var file in Directory.GetFiles(folder))
                {
                    var result = new TopicStreamResult(file);

                    var key = Tuple.Create(result.CopyFactor, result.FocusCount, result.TreeCount);
                    Dictionary <int, double> value;
                    if (!statDictionary.TryGetValue(key, out value))
                    {
                        value = new Dictionary <int, double>();
                        statDictionary.Add(key, value);
                    }
                    value.Add(result.DefaultTreeCutRandomSeed,
                              (result.TreeCutTime + (isAddVisTime ? result.VisTime : 0.0) + result.DAGTime +
                               result.SedimentationTime));
                    focusSeeds.Add(result.DefaultTreeCutRandomSeed);

                    copyFactors.Add(result.CopyFactor);
                    focusCounts.Add(result.FocusCount);
                    treeCounts.Add(result.TreeCount);
                }
            }

            if (copyFactors.Count != 1)
            {
                throw new ArgumentException();
            }
            var treeCountList = new List <int>(treeCounts);

            treeCountList.Sort();
            var focusCountList = new List <int>(focusCounts);

            focusCountList.Sort();
            var focusSeedList = new List <int>(focusSeeds);

            focusSeedList.Sort();
            var singleCopyFactor = copyFactors.First();

            double[,] matrices = new double[treeCountList.Count - 1, focusCountList.Count];
            int copyFactorIndex = 0;
            int minTreeCnt      = treeCountList.First();
            var deltaTreeCount  = treeCountList[1] - treeCountList[0];

            foreach (var treeCount in treeCountList)
            {
                if (treeCount == minTreeCnt)
                {
                    continue;
                }
                int focusCountIndex = 0;
                foreach (var focusCount in focusCountList)
                {
                    var tuple1 = Tuple.Create(singleCopyFactor, focusCount, treeCount - deltaTreeCount);
                    var tuple2 = Tuple.Create(singleCopyFactor, focusCount, treeCount);

                    DoubleStatistics stat = new DoubleStatistics();
                    var dict1             = statDictionary[tuple1];
                    var dict2             = statDictionary[tuple2];

                    //if (dict1.Count != 50 || dict2.Count != 50)
                    //{
                    //    throw new ArgumentException();
                    //}

                    foreach (var focusSeed in focusSeedList)
                    {
                        double time1, time2;
                        if (dict1.TryGetValue(focusSeed, out time1) & dict2.TryGetValue(focusSeed, out time2))
                        {
                            stat.AddNumber(Math.Max(time2 - time1, 0));
                        }
                    }
                    matrices[copyFactorIndex, focusCountIndex] = stat.GetAverage();
                    focusCountIndex++;
                }
                copyFactorIndex++;
            }

            Console.Write("[");
            for (int j = 0; j < treeCountList.Count - 1; j++)
            {
                for (int k = 0; k < focusCountList.Count; k++)
                {
                    Console.Write(matrices[j, k] + (k == focusCountList.Count - 1 ? ";" : ","));
                }
                if (j == treeCountList.Count - 1)
                {
                    Console.WriteLine("]/1000;");
                }
                else
                {
                    Console.WriteLine("...");
                }
            }
            Console.WriteLine();
        }