private List <TestingPageModel> GetSpeedsForExistingSitemap(XmlDocument xmlDoc)
        {
            var        measures = new List <TestingPageModel>();
            XmlElement xRoot    = xmlDoc.DocumentElement;

            foreach (XmlNode xnode in xRoot)
            {
                foreach (XmlNode childNodes in xnode.ChildNodes)
                {
                    if (childNodes.Name == "loc")
                    {
                        var currentPage = new TestingPageModel();
                        currentPage.PageUrl = childNodes.InnerText;

                        try
                        {
                            Stopwatch timer = new Stopwatch();
                            timer.Start();
                            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(currentPage.PageUrl);
                            //request.UserAgent = "My User Agent";

                            HttpWebResponse response = (HttpWebResponse)request.GetResponse();

                            timer.Stop();
                            currentPage.CurrentResponseTime = timer.Elapsed.TotalMilliseconds;
                            currentPage.Speeds.Add(new PageSpeedModel {
                                Speed = currentPage.CurrentResponseTime
                            });
                        }
                        catch
                        {
                            currentPage.CurrentResponseTime = 0;
                        }

                        measures.Add(currentPage);
                    }
                }
            }
            return(measures);
        }
        private List <TestingPageModel> GetSpeedsForCreatedSitemap(string sitemap)
        {
            int endPartUrl = 12;
            var measures   = new List <TestingPageModel>();
            var url        = sitemap.Substring(0, sitemap.Length - endPartUrl);
            var pages      = PageParser(url);

            foreach (var page in pages)
            {
                var currentPage = new TestingPageModel();
                currentPage.PageUrl = page;

                try
                {
                    Stopwatch timer = new Stopwatch();
                    timer.Start();
                    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(currentPage.PageUrl);
                    //request.UserAgent = "My User Agent";

                    HttpWebResponse response = (HttpWebResponse)request.GetResponse();

                    timer.Stop();
                    currentPage.CurrentResponseTime = timer.Elapsed.TotalMilliseconds;
                    currentPage.Speeds.Add(new PageSpeedModel {
                        Speed = currentPage.CurrentResponseTime
                    });
                }
                catch
                {
                    currentPage.CurrentResponseTime = 0;
                }

                measures.Add(currentPage);
            }
            return(measures);
        }