Exemplo n.º 1
0
        public void Can_Deep_Clone_Perf_Test()
        {
            // Arrange
            var contentType = MockedContentTypes.CreateTextpageContentType();

            contentType.Id = 99;
            var content = MockedContent.CreateTextpageContent(contentType, "Textpage", -1);
            var i       = 200;

            foreach (var property in content.Properties)
            {
                property.Id = ++i;
            }
            content.Id          = 10;
            content.CreateDate  = DateTime.Now;
            content.CreatorId   = 22;
            content.ExpireDate  = DateTime.Now;
            content.Key         = Guid.NewGuid();
            content.Language    = "en";
            content.Level       = 3;
            content.Path        = "-1,4,10";
            content.ReleaseDate = DateTime.Now;
            content.ChangePublishedState(PublishedState.Published);
            content.SortOrder = 5;
            content.Template  = new Template("-1,2,3,4", "Test Template", "testTemplate")
            {
                Id = 88
            };
            content.Trashed    = false;
            content.UpdateDate = DateTime.Now;
            content.Version    = Guid.NewGuid();
            content.WriterId   = 23;

            ((IUmbracoEntity)content).AdditionalData.Add("test1", 123);
            ((IUmbracoEntity)content).AdditionalData.Add("test2", "hello");

            var runtimeCache = new ObjectCacheRuntimeCacheProvider();

            runtimeCache.InsertCacheItem(content.Id.ToString(CultureInfo.InvariantCulture), () => content);

            using (DisposableTimer.DebugDuration <ContentTests>("STARTING PERF TEST WITH RUNTIME CACHE"))
            {
                for (int j = 0; j < 1000; j++)
                {
                    var clone = runtimeCache.GetCacheItem(content.Id.ToString(CultureInfo.InvariantCulture));
                }
            }

            using (DisposableTimer.DebugDuration <ContentTests>("STARTING PERF TEST WITHOUT RUNTIME CACHE"))
            {
                for (int j = 0; j < 1000; j++)
                {
                    var clone = (ContentType)contentType.DeepClone();
                }
            }
        }
Exemplo n.º 2
0
        public void Can_Deep_Clone_Perf_Test()
        {
            // Arrange
            var contentType = MockedContentTypes.CreateTextPageContentType();

            contentType.Id = 99;
            var content = MockedContent.CreateTextpageContent(contentType, "Textpage", -1);
            var i       = 200;

            foreach (var property in content.Properties)
            {
                property.Id = ++i;
            }
            content.Id         = 10;
            content.CreateDate = DateTime.Now;
            content.CreatorId  = 22;
            content.Key        = Guid.NewGuid();
            content.Level      = 3;
            content.Path       = "-1,4,10";
            content.ContentSchedule.Add(DateTime.Now, DateTime.Now.AddDays(1));
            //content.ChangePublishedState(PublishedState.Published);
            content.SortOrder  = 5;
            content.TemplateId = 88;
            content.Trashed    = false;
            content.UpdateDate = DateTime.Now;
            content.WriterId   = 23;

            var runtimeCache = new ObjectCacheRuntimeCacheProvider();

            runtimeCache.InsertCacheItem(content.Id.ToString(CultureInfo.InvariantCulture), () => content);

            var proflog = GetTestProfilingLogger();

            using (proflog.DebugDuration <ContentTests>("STARTING PERF TEST WITH RUNTIME CACHE"))
            {
                for (int j = 0; j < 1000; j++)
                {
                    var clone = runtimeCache.GetCacheItem(content.Id.ToString(CultureInfo.InvariantCulture));
                }
            }

            using (proflog.DebugDuration <ContentTests>("STARTING PERF TEST WITHOUT RUNTIME CACHE"))
            {
                for (int j = 0; j < 1000; j++)
                {
                    var clone = (ContentType)contentType.DeepClone();
                }
            }
        }