Improve conversion speed for DWG files in .NET

Hi,

I’m wondering if there are some ways to improve the general conversion speed in GroupDocs.Viewer (21.8) for DWG files in particular.
The attached file for example takes over 10 seconds on my system to convert.
K03.10289.101.1_REV4.dwg.zip (3.4 MB)

As we want to use GroupDocs.Viewer as a live-viewer, we want to keep our customer’s waiting time to a minimum.
Are there any options or ways to improve the conversion time, even if they sacrifice quality?
Generally and specific to DWG files?

@Clemens_Pestuka

Thank you for attaching the sample file. I’ve got similar results to yours when it was a cold start, all subsequent conversions took 6-7 seconds on my system.

When talking about CAD drawings the conversion time depends on count of entities a drawing has but the moment we do not provide any options that may improve CAD files conversion time but we’ll investigate such possibility in VIEWERNET-3561.

1 Like

@vladimir.litvinchik

Thank you for the quick reply.
I just re-tested it with a console program release build, as I was previously testing in debug mode.
But I have to say it was still taking 10-11 seconds, even when converting the file a second time. (Creating a 2nd Viewer instance)
I’m wondering what you are doing differently?

Thank you as well for the further investigation. :+1:

@Clemens_Pestuka

I’m sorry for the delayed response. I’ve been using sample_app.zip (3.4 MB) to run the conversion in a loop. Here is results that I’ve got when running the app that targeting .NET Framework 4.8

Iteration 0; Elapsed 11305ms
Iteration 1; Elapsed 7767ms
Iteration 2; Elapsed 7625ms
Iteration 3; Elapsed 7643ms
Iteration 4; Elapsed 7788ms
Iteration 5; Elapsed 7686ms
Iteration 6; Elapsed 8193ms
Iteration 7; Elapsed 7787ms
Iteration 8; Elapsed 7736ms
Iteration 9; Elapsed 7327ms

When targeting .NET 5

Iteration 0; Elapsed 9911ms
Iteration 1; Elapsed 6933ms
Iteration 2; Elapsed 6536ms
Iteration 3; Elapsed 6650ms
Iteration 4; Elapsed 5958ms
Iteration 5; Elapsed 6859ms
Iteration 6; Elapsed 6275ms
Iteration 8; Elapsed 6316ms
Iteration 9; Elapsed 6165ms

We’ll take a look at how we can improve performance and update you here.

1 Like

@vladimir.litvinchik

Thanks a lot for the sample!
The results were quite a big surprise for me.

Running you application with .NET Core 3.1 lead to the best results:

Iteration 0; Elapsed 8576ms
Iteration 1; Elapsed 5613ms
Iteration 2; Elapsed 5517ms
Iteration 3; Elapsed 5575ms
Iteration 4; Elapsed 5530ms
Iteration 5; Elapsed 5593ms
Iteration 6; Elapsed 5519ms
Iteration 7; Elapsed 5494ms
Iteration 8; Elapsed 5481ms
Iteration 9; Elapsed 5529ms

Using .NET Framework 4.7 was quite a big performance hit:

Iteration 0; Elapsed 10522ms
Iteration 1; Elapsed 7884ms
Iteration 2; Elapsed 7696ms
Iteration 3; Elapsed 7869ms
Iteration 4; Elapsed 8110ms
Iteration 5; Elapsed 7876ms
Iteration 6; Elapsed 7896ms
Iteration 7; Elapsed 7880ms
Iteration 8; Elapsed 7940ms
Iteration 9; Elapsed 7816ms

Having GroupDocs.Conversion in the same project (without using it in the sample),
did add another second to the conversion time:

Iteration 0; Elapsed 10228ms
Iteration 1; Elapsed 8710ms
Iteration 2; Elapsed 8809ms
Iteration 3; Elapsed 8824ms
Iteration 4; Elapsed 8745ms
Iteration 5; Elapsed 8715ms
Iteration 6; Elapsed 8706ms
Iteration 7; Elapsed 8782ms
Iteration 8; Elapsed 8731ms
Iteration 9; Elapsed 9066ms

I also noticed, that using the same file in all runs, “improves” performance as well.
When I was loading a different DWG as “warm up”, it did not improve the performance as much.
Those were my first values inside the loop, after loading a different file before the loop:

Iteration 0; Elapsed 9193ms
Iteration 0; Elapsed 9180ms
Iteration 0; Elapsed 9044ms
Iteration 0; Elapsed 8959ms
Iteration 0; Elapsed 9137ms

So between 5.5 and 9.1 seconds is quite a difference.
And this only happens with .NET Framework, not with .NET Core as it seems.
Is this something you will be able to fix, or should we attempt to move our project to .NET Core?
GroupDocsViewerSpeed.zip (3.5 MB)

@Clemens_Pestuka

Thanks for sharing the results that you’ve got. The best results that in my case were with .NET 6 and pre-release version of v21.9

Iteration 0; Elapsed 11037ms
Iteration 1; Elapsed 6476ms
Iteration 2; Elapsed 6089ms
Iteration 3; Elapsed 6097ms
Iteration 4; Elapsed 6022ms
Iteration 5; Elapsed 6132ms
Iteration 6; Elapsed 6153ms
Iteration 7; Elapsed 5988ms
Iteration 8; Elapsed 6299ms
Iteration 9; Elapsed 5939ms

We’ll take a look at what we can do from our side to improve conversion speed. What about .NET Core and .NET - I would definitely give it a try due to a number of performance improvements that has been introduced in .NET Core and .NET.

1 Like

@vladimir.litvinchik

Thank you for the feedback and suggestion :slight_smile:
I’ll keep testing if .NET Core will be a general improvement or if the time difference was just specific to that file.
If it really speeds up conversion time in general I’ll attempt to move our project to .NET Core as suggested.

@Clemens_Pestuka

Sure, let us know if you have and issues with switching to .NET Core and we’ll try to assist you.

1 Like

@Clemens_Pestuka

In GroupDocs.Viewer for .NET 24.2 we have added new feature that improves conversion speed for CAD drawings. Set EnablePerformanceConversionMode to true to improve conversion performance:

using (Viewer viewer = new Viewer("input.dwg"))
{
   HtmlViewOptions viewOptions = HtmlViewOptions.ForEmbeddedResources("Output-Page#{0}.html");                    
   viewOptions.CadOptions = CadOptions.ForRenderingByWidth(1000);
   viewOptions.CadOptions.EnablePerformanceConversionMode = true;

   viewer.View(viewOptions);
}

See Choose rendering speed instead of quality documentation topic for more details.

1 Like