Exemple #1
0
        public void SetUp()
        {
            domain = new FavoriteLinkDomain();

            _userId1    = new Guid("{E18369A7-99F7-486d-8F0B-96347ABF04ED}");
            _userId2    = new Guid("{E18369A7-99F7-486d-8F0B-96347ABF04EE}");
            _profileId1 = domain.GetFavoriteLinkProfileID(_userId1);
            _profileId2 = domain.GetFavoriteLinkProfileID(_userId2);
        }
Exemple #2
0
        public void Test350_LoadTest()
        {
            if (!_enableLoadTesting)
            {
                return;
            }
            String titleFormat = "Link {0}";
            String urlFormat   = "http://testurl/{0}.html";

            TimeKeeper timeKeeper = new TimeKeeper();
            int        maxLinks   = 1000;
            double     totalReflectionCastingTime = 0;
            double     totalDirectCastingTime     = 0;

            Console.WriteLine(String.Format("Starting test with {0} links", maxLinks));

            for (int i = 1; i <= maxLinks; i++)
            {
                string title = String.Format(titleFormat, i);
                string url   = String.Format(urlFormat, i);
                domain.SaveFavoriteLink(_profileId1, title, url, true, 3, "A link", "loadtest", -1);
            }

            DataSet ds = domain.GetFavoriteLinksByProfileID(_profileId1);

            FavoriteLink.SelectedCastingMode = CastingMode.ReflectionCasting;
            timeKeeper.Start();
            FavoriteLinkCollection collection1 = new FavoriteLinkCollection();

            foreach (DataRow row in ds.Tables[0].Rows)
            {
                FavoriteLink link = domain.Convert(row);
                collection1.Add(link);
            }
            timeKeeper.Stop();
            totalReflectionCastingTime += timeKeeper.Duration;
            timeKeeper.Reset();

            FavoriteLink.SelectedCastingMode = CastingMode.DirectCasting;
            timeKeeper.Start();
            FavoriteLinkCollection collection2 = new FavoriteLinkCollection();

            foreach (DataRow row in ds.Tables[0].Rows)
            {
                FavoriteLink link = domain.Convert(row);
                collection2.Add(link);
            }
            timeKeeper.Stop();
            totalDirectCastingTime += timeKeeper.Duration;
            timeKeeper.Reset();

            Console.WriteLine(String.Format("Max Links: {0}", maxLinks));
            double avgReflectionTime = totalReflectionCastingTime / maxLinks * 1000;
            double avgDirectTime     = totalDirectCastingTime / maxLinks * 1000;

            Console.WriteLine(String.Format("Avg Reflection Casting Time: {0} ms", avgReflectionTime));
            Console.WriteLine(String.Format("Avg Direct Casting Time: {0} ms", avgDirectTime));

            domain.PurgeProfile(_profileId1);
            _profileId1 = domain.GetFavoriteLinkProfileID(_userId1);
        }