コード例 #1
0
ファイル: TestingClass.cs プロジェクト: valkiria88/Astoria
        private void checkPath(string command)
        {
            string[] cpieces = command.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            if (cpieces.Length < 2)
            {
                Console.WriteLine("error: usage checkpath <path (comma seperated)>");
                return;
            }

            string[] temp = cpieces[1].Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);

            PathChecker pathChecker = new PathChecker();
            int dest;
            int.TryParse(temp[temp.Length -1], out dest);

            Stopwatch stopwatch = new Stopwatch();
            stopwatch.Start();

            List<UInt32>[] bestNew = pathChecker.deserializeBestNew(dest, "z\\");

            Console.WriteLine("Time to Load Binary: {0} ms", stopwatch.ElapsedMilliseconds);
            stopwatch.Stop();
            stopwatch.Reset();

            if (bestNew == null)
            {
                Console.WriteLine("Could not find file to desrialise!");
                return;
            }

            if (pathChecker.pathAvailable(cpieces[1], bestNew))
            { Console.WriteLine("Path Found!"); }
            else
            { Console.WriteLine("Path Not Found!"); }

            stopwatch.Start();
            for (int j = 0; j < 100; j++)
            {
                pathChecker.pathAvailable(cpieces[1], bestNew);
            }
            stopwatch.Stop();
            Console.WriteLine("Time to check 100 paths: {0} ms", stopwatch.ElapsedMilliseconds);
            stopwatch.Reset();

            stopwatch.Start();
            for (int j = 0; j < 1000; j++)
            {
                pathChecker.pathAvailable(cpieces[1], bestNew);
            }
            stopwatch.Stop();
            Console.WriteLine("Time to check 1000 paths: {0} ms", stopwatch.ElapsedMilliseconds);
            stopwatch.Reset();

            stopwatch.Start();
            for (int j = 0; j < 10000; j++)
            {
                pathChecker.pathAvailable(cpieces[1], bestNew);
            }
            stopwatch.Stop();
            Console.WriteLine("Time to check 10000 paths: {0} ms", stopwatch.ElapsedMilliseconds);
            stopwatch.Reset();

            stopwatch.Start();
            for (int j = 0; j < 100000; j++)
            {
                pathChecker.pathAvailable(cpieces[1], bestNew);
            }
            stopwatch.Stop();
            Console.WriteLine("Time to check 100000 paths: {0} ms", stopwatch.ElapsedMilliseconds);
            stopwatch.Reset();
        }
コード例 #2
0
ファイル: TestingClass.cs プロジェクト: valkiria88/Astoria
        private bool analysePath(ref NetworkGraph graph, string command)
        {
            string[] cpieces = command.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            if (cpieces.Length < 3)
            {
                Console.WriteLine("error: usage analysepath <dstnum> <path>");
                return false;
            }

            int dstNum;
            string path = cpieces[2];

            if (!int.TryParse(cpieces[1], out dstNum))
            {
                Console.WriteLine("invalid destination.");
                return false;
            }

            PathChecker pathChecker = new PathChecker();

            if (dstNum > Constants._numASNs)
            {
                return false;
            }

            Destination newD2 = new Destination();
            if (initDestination(ref graph, ref newD2, "destination " + dstNum))
            {
                Console.WriteLine("HN: initialized " + newD2.destination);

                pathChecker.pathAnalysis(path, ref newD2);
                return true;
            }
            return false;
        }
コード例 #3
0
ファイル: TestingClass.cs プロジェクト: valkiria88/Astoria
        private void analysePathfile(ref NetworkGraph graph, string command)
        {
            string[] cpieces = command.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            if (cpieces.Length < 2)
            {
                Console.WriteLine("error: usage analysepathfile <filename>");
                return;
            }

            TextWriter tw = new StreamWriter("result_bucket.txt");
            TextWriter twViolation = new StreamWriter("violation_bucket.txt");
            TextWriter twMissing = new StreamWriter("missing_bucket.txt");
            TextWriter twRandom = new StreamWriter("random_file.txt");
            //for (int i = 0; i < allPaths.Count; i++)
            //{
            //    tw.WriteLine(pathString(allPaths[i]));
            //}
            //tw.Close();

            using (var reader = new StreamReader(cpieces[1]))
            {
                PathChecker pathChecker = new PathChecker();
                Destination newD2 = new Destination();
                initDestination(ref graph, ref newD2, "destination " + "1");

                string line;
                while ((line = reader.ReadLine()) != null)
                {
                    string[] lpieces = line.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                    if (lpieces.Length == 2)
                    {
                        int dstNum;
                        string path = lpieces[1];

                        if (!int.TryParse(lpieces[0], out dstNum))
                        {
                            Console.WriteLine("invalid destination. " + lpieces[0]);
                            continue;
                        }
                        if (dstNum > Constants._numASNs)
                        {
                            continue;
                        }

                        if (dstNum != newD2.destination)
                        {
                            try
                            {
                                initDestination(ref graph, ref newD2, "destination " + dstNum);
                            }
                            catch (Exception x)
                            {
                                Console.Out.WriteLine("Exception computing dest: " + dstNum);
                                continue;
                            }
                        }
                        try
                        {
                            string result = pathChecker.pathAnalysis(path, ref newD2, ref twMissing, ref twRandom, ref twViolation);
                            tw.WriteLine(result); tw.Flush();
                        }
                        catch (Exception y)
                        {
                            Console.Out.WriteLine("Exception analysing path: " + path);
                            continue;
                        }
                    }
                }
            }
            tw.Close();
            twMissing.Close();
            twRandom.Close();
        }
コード例 #4
0
ファイル: TestingClass.cs プロジェクト: valkiria88/Astoria
        private bool serialisePathArrays(ref NetworkGraph graph, string command)
        {
            string[] cpieces = command.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            if (cpieces.Length < 3)
            {
                Console.WriteLine("error: usage serialise <dstnum> <path>");
                return false;
            }

            int dstNum;
            string path;

            if (!int.TryParse(cpieces[1], out dstNum))
            {
                Console.WriteLine("invalid destination.");
                return false;
            }

            PathChecker pathChecker = new PathChecker();

            if (dstNum == -1)
            {
                for (int i = 0; i < Constants._numASNs; i++)
                {
                    Destination newD = new Destination();
                    try
                    {
                        if (initDestination(ref graph, ref newD, "destination " + i))
                        {
                            pathChecker.serializeBestNew(newD.BestNew, i, cpieces[2]);
                        }
                    }
                    catch(Exception)
                    {
                    }
                }
                return true;
            }

            Destination newD2 = new Destination();
            if (initDestination(ref graph, ref newD2, "destination " + dstNum))
            {
                Console.WriteLine("HN: initialized " + newD2.destination + "\t Calling serialiser");

                pathChecker.serializeBestNew(newD2.BestNew, dstNum, cpieces[2]);

                return true;
            }

            return false;
        }