diff --git a/QuestPDF.ReportSample/Layouts/PhotoTemplate.cs b/QuestPDF.ReportSample/Layouts/PhotoTemplate.cs index 8384147..b265d03 100644 --- a/QuestPDF.ReportSample/Layouts/PhotoTemplate.cs +++ b/QuestPDF.ReportSample/Layouts/PhotoTemplate.cs @@ -30,14 +30,14 @@ namespace QuestPDF.ReportSample.Layouts container .Row(row => { - row.RelativeColumn(2).AspectRatio(4 / 3f).Image(Placeholders.Image); + row.RelativeColumn(2).AspectRatio(4 / 3f).Background(Colors.Grey.Lighten3); row.RelativeColumn().PaddingLeft(5).Stack(stack => { stack.Spacing(7f); - stack.Item().AspectRatio(4 / 3f).Image(Placeholders.Image); - stack.Item().AspectRatio(4 / 3f).Image(Placeholders.Image); + stack.Item().AspectRatio(4 / 3f).Background(Colors.Grey.Lighten3); + stack.Item().AspectRatio(4 / 3f).Background(Colors.Grey.Lighten3); }); }); } diff --git a/QuestPDF.ReportSample/Layouts/SectionTemplate.cs b/QuestPDF.ReportSample/Layouts/SectionTemplate.cs index e59ba07..178bc0c 100644 --- a/QuestPDF.ReportSample/Layouts/SectionTemplate.cs +++ b/QuestPDF.ReportSample/Layouts/SectionTemplate.cs @@ -59,7 +59,7 @@ namespace QuestPDF.ReportSample.Layouts { stack.Spacing(5); - stack.Item().MaxWidth(250).AspectRatio(4 / 3f).Image(Placeholders.Image); + stack.Item().MaxWidth(250).AspectRatio(4 / 3f).Background(Colors.Grey.Lighten3); stack.Item().Text(model.Location.Format(), Typography.Normal); }); } @@ -77,7 +77,7 @@ namespace QuestPDF.ReportSample.Layouts grid.Spacing(5); grid.Columns(3); - model.Photos.ForEach(x => grid.Item().AspectRatio(4 / 3f).Image(Placeholders.Image)); + model.Photos.ForEach(x => grid.Item().AspectRatio(4 / 3f).Background(Colors.Grey.Lighten3)); }); } } diff --git a/QuestPDF.ReportSample/Layouts/StandardReport.cs b/QuestPDF.ReportSample/Layouts/StandardReport.cs index c130b82..8f4b2f8 100644 --- a/QuestPDF.ReportSample/Layouts/StandardReport.cs +++ b/QuestPDF.ReportSample/Layouts/StandardReport.cs @@ -55,7 +55,7 @@ namespace QuestPDF.ReportSample.Layouts row.Spacing(50); row.RelativeColumn().PaddingTop(-10).Text(Model.Title, Typography.Title); - row.ConstantColumn(150).ExternalLink("https://www.questpdf.com").Image(Model.LogoData); + row.ConstantColumn(150).ExternalLink("https://www.questpdf.com").Background(Colors.Grey.Lighten3); }); stack.Item().ShowOnce().PaddingVertical(15).Border(1f).BorderColor(Colors.Grey.Lighten1).ExtendHorizontal(); diff --git a/QuestPDF.ReportSample/PerformanceTests.cs b/QuestPDF.ReportSample/PerformanceTests.cs index e3b2fcc..7e50249 100644 --- a/QuestPDF.ReportSample/PerformanceTests.cs +++ b/QuestPDF.ReportSample/PerformanceTests.cs @@ -1,4 +1,6 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using BenchmarkDotNet.Attributes; using BenchmarkDotNet.Configs; @@ -7,6 +9,8 @@ using BenchmarkDotNet.Running; using Microsoft.VisualStudio.TestPlatform.TestHost; using NUnit.Framework; using QuestPDF.Drawing; +using QuestPDF.Drawing.Proxy; +using QuestPDF.Elements; using QuestPDF.Infrastructure; using QuestPDF.ReportSample.Layouts; @@ -16,7 +20,9 @@ namespace QuestPDF.ReportSample [MinColumn, MaxColumn, MeanColumn, MedianColumn] public class PerformanceTests { - private StandardReport Report { get; set; } + private PageContext PageContext { get; set; } + private DocumentMetadata Metadata { get; set; } + private Container Content { get; set; } [Test] public void Run() @@ -32,21 +38,33 @@ namespace QuestPDF.ReportSample public void GenerateReportData() { var model = DataSource.GetReport(); - Report = new StandardReport(model); + var report = new StandardReport(model); + Metadata = report.GetMetadata(); + + var documentContainer = new DocumentContainer(); + report.Compose(documentContainer); + Content = documentContainer.Compose(); + + PageContext = new PageContext(); + DocumentGenerator.RenderPass(PageContext, new FreeCanvas(), Content, Metadata, null); + + var sw = new Stopwatch(); + sw.Start(); + + Content.HandleVisitor(x => + { + if (x is ICacheable) + x.CreateProxy(y => new CacheProxy(y)); + }); + + sw.Stop(); + Console.WriteLine($"Creating cache took: {sw.ElapsedMilliseconds}"); } [Benchmark] public void GenerationTest() { - var container = new DocumentContainer(); - Report.Compose(container); - var content = container.Compose(); - - var metadata = Report.GetMetadata(); - var pageContext = new PageContext(); - - DocumentGenerator.RenderPass(pageContext, new FreeCanvas(), content, metadata, null); - DocumentGenerator.RenderPass(pageContext, new FreeCanvas(), content, metadata, null); + DocumentGenerator.RenderPass(PageContext, new FreeCanvas(), Content, Metadata, null); } } } \ No newline at end of file