Guidelines for optimizing performance of initial rendering

We’d like to see what we can do to maximize performance of the Groupdocs engine. I’ve looked through the documentation, blogs, and searched the forums, but I haven’t found any performance guidelines.



My questions are:

1. Is there anything we can use to measure the actual time consumed by the rendering engine to isolate it from the document download?

2. Are some kinds of streams more performant than others?

3. How does the Quality or other parameters that can be configured on the ClientHelper object influence rendering speed?



Thanks,

Don

Hello Don,

Thank you for your deep interest in GroupDocs.Viewer and for your desire to know how it works inside and how to achieve max performance.

We are working on performance guideline right now and will release it as soon as possible.

1. GroupDocs.Viewer is a client-server middleware and it uses asynchronous requests while displaying a document. So in fact measuring page download and rendering time is useless, because GroupDocs.Viewer starts to work only when page downloading is complete. You can try to measure time in request/response scanner (for example, “Network” tab in Google Chrome or Firebug in Mozilla Firefox), but this measurement will not be accurate and appropriate for different reasons.

2. Please specify what do you mean under “kinds of streams”? If you mean streams that inherit from System.IO.Stream (like FileStream, MemoryStream and so on) - it does not matter for GroupDocs.Viewer, because it simply reads stream’s content and writes it to the local file. So if stream reading operation is fast, Viewer will read this stream fast; if slow - then slow. Please read an article “How to Use GroupDocs.Viewer with Streams in ASP.NET MVC or WebForms Projects” for more details.

3. There are several things that you need to know in order to achieve max performance:
3.1. You should use HTML-based rendering mode instead of image-based when your document is mostly text-oriented rather then image-, layout-oriented. In other words, if you are looking the best performance, document contains mostly text and you are agreed with little distortion - HTML-based rendering mode is what you need. In order to enable it use “.UseHtmlBasedEngine(true)”.
3.2. “Quality” method is applicable for image-based rendering mode. In this mode every page of the document is rasterized to the separate image, and “Quality” specifies the quality of this rasterization. Default quality (if this method is omitted) is 100%. However when you specify another quality, GroupDocs.Viewer will rasterize document into two qualities: 100% and yours selected quality. So every page will be rasterized twice instead of one time. This parameter makes sence when you need to reach very small amount of data that should be transferred between server and client (this is suitable, for example, for mobile devices with 3G, where internet traffic should be low), because the lesser is quality - the smaller is image size.
3.3. You can use ahead-of-time caching. By default when document is displayed at first time, it is cached, and when this document will be displayed again, GroupDocs.Viewer will use cached data. But if you are concerned of first-time displaying performance, you can do ahead-of-time caching using “DocumentCache” class. Article “Description of GroupDocs Viewer DocumentCache class” can give you more details.
3.4. You can use method “.PreloadPagesCount(Int32)”. By default document’s parsed content will be sent to the client only when all pages will be parsed. Using “PreloadPagesCount” method you can specify, after what amount of parsed pages server should start to transfer content to the client. For example, “.PreloadPagesCount(1)” allows you to see first page almost instantly, but scrolling down, page thumbnails will require additional time to load.

We are constantly working to improve GroupDocs.Viewer, to expand its functionality and speed-up performance. So please stay tuned.

If you will have more questions please feel free to contact us.