Symbol attributes / Text rendering performance
Chris Smith
2/15/2022 11:40 AM
|
---|
Hi Wout and co,
Given the improvement we saw with the font thing, I thought I should post the other two "hot" areas we see in CadLib and see if there's anything that can be done to improve those.
The first is DxfInsert.AddAttribute which is currently taking about 30 seconds out of 150 seconds in our test cases - there are 29 calls to this (so approx 1 second per call).
Our code to call this looks like:
C# Code: var dxfAttributeDefinitions = dxfBlock. |
Wout
2/15/2022 11:58 AM
|
---|
Hi Chris,
The text rendering itself I probably can't get any faster, but the AddAttribute elapsed time of 1 second sounds excessive, I'd expect it to be milliseconds. Internally it does layout/render (to get the text bounds) the attribute text because of alignment, so it's not a super cheap operation, but I wouldn't think 1 second.
If you use left/baseline alignment on the text the code won't even try to align the text, and it skips the expensive layout and alignment call. On any other alignment, it will have to calculate the text bounds to layout the text properly.
You can send me a file and a test program to try it out.
- Wout
|
Chris Smith
2/16/2022 9:21 AM
|
---|
Hi Wout,
I've emailed you 4 sample DWG files that are indicative of the more complex type of graphics we would render.
They're only a few hundred entities each so generally not too much but we'd be rendering a lot of these small drawings very quickly.
Re the text rendering - fair enough - the only thing that seemed odd there was that the Text objects (which I assume are actually the block reference attributes) took quite a bit longer to render than the MText even tho there was more MText. I will say that typically our cusotomers' block attributes are center aligned whereas their MText might be more likely to be left aligned.
Re the FixAlignmentPoints call, is there any possibility of caching something about the font or etc which might speed that up?
Also, and maybe this is a bit related to the GDI+ error I mentioned elsewhere, but I'm wondering if CadLib will internally ignore features that are entirely outside the render viewport? I can see we've put a bunch of features that are actually outside the area we're going to render in the drawing, so maybe we could filter these out again before we call CreateBitmap. Not sure if its going to be faster to calculate their bounds or just to render them tho...
Cheers,
Chris
|
Chris Smith
2/16/2022 10:57 AM
|
---|
So I tried using the BoundsCalculator to work out if symbols were within the viewport and that was very expensive so don't do that 🙂
Will see if we can reduce the amount of graphics some other way.
|
Wout
2/16/2022 12:20 PM
|
---|
Hi,
Can you create a Console application to recreate the adding of attributes scenario? I can't compile the code above.
- Wout
|
Chris Smith
2/16/2022 12:24 PM
|
---|
Hi Wout,
I should be able to - I'll have to look at it tomorrow tho.
Cheers,
Chris
|