Exemplo n.º 1
0
        void FilterRequests()
        {
            var watch = System.Diagnostics.Stopwatch.StartNew();

            // 1. Usuwamy requesty z endpointów bez cache
            List <Endpoint> endpointsToRemove = new List <Endpoint>();

            foreach (Endpoint endpoint in allEndpoints)
            {
                if (endpoint.latenciesToCaches.Count == 0)
                {
                    endpointsToRemove.Add(endpoint);
                }
            }
            for (int i = 0; i < endpointsToRemove.Count; i++)
            {
                allEndpoints.Remove(endpointsToRemove[i]);
            }

            // 2. Usuwamy requesty na filmy, które przekraczają maxSize
            foreach (Endpoint endpoint in allEndpoints)
            {
                for (int i = 0; i < endpoint.requests.Count; i++)
                {
                    Request req = endpoint.requests[i];
                    if (req.video.size > maxSize)
                    {
                        endpoint.requests.Remove(req);
                    }
                }
            }

            watch.Stop();
            ProgramExtender.LogPerformanceMetric("filtering requests", watch);
        }
Exemplo n.º 2
0
        void EvaluateAndFillCaches()
        {
            var watch = System.Diagnostics.Stopwatch.StartNew();

            if (parallelCacheEvaluation)
            {
                Parallel.ForEach(SortCaches(), cache => cache.EvaluateAndFillWithVideos());
            }
            else
            {
                foreach (var cache in SortCaches())
                {
                    cache.EvaluateAndFillWithVideos();
                }
            }

            watch.Stop();
            ProgramExtender.LogPerformanceMetric("evaluating and filling caches", watch);
        }
Exemplo n.º 3
0
        void ParseData()
        {
            string[] inputLines = null;
            if (parseMethod == ParseMethod.ParseFromFile)
            {
                string filename = Console.ReadLine();
                inputLines = this.ReadDataFromFile(filename);
            }
            else if (parseMethod == ParseMethod.ParseFromConsole)
            {
                inputLines = this.ReadDataFromConsole();
            }

            var watch = System.Diagnostics.Stopwatch.StartNew();

            this.ParseDataFromLines(inputLines);
            watch.Stop();
            ProgramExtender.LogPerformanceMetric("parsing input data", watch);
        }
Exemplo n.º 4
0
        void OutputResults()
        {
            var watch = System.Diagnostics.Stopwatch.StartNew();

            List <Cache> usedCaches = new List <Cache>();

            foreach (var cache in allCaches)
            {
                if (cache.IsUsed())
                {
                    usedCaches.Add(cache);
                }
            }

            Console.WriteLine(usedCaches.Count);

            foreach (var cache in usedCaches)
            {
                Console.WriteLine(cache);
            }

            watch.Stop();
            ProgramExtender.LogPerformanceMetric("printing results", watch);
        }