Performance issues and Visio application upgrades

  • Thread starter Mats-Lennart Hansson
  • Start date
M

Mats-Lennart Hansson

Hi,
I am currently developing a Visio solution where one of the features
includes importing shapes and pages into an empty document. I have noticed
that importing a large number of shapes (i.e. about 5000) is very time
consuming. I have optimized my code using DropMany, DeferRecalc, ShowChanges
etc, which increased the performance a lot but not enough I think... I have
thought of generating a Data Diagram ML structure instead and then save this
XML as a Visio document in order to import the shapes. I have a feeling that
if this was possible it would be faster than using the Visio object model.
Do you think this is a good idea?

Another thought: How do you handle upgrades of Visio applications like mine?
I mean, assume that someone spends a month to create a huge Visio docucment
with thousands of shapes. Then, due to an upgrade of the Visio application,
all of the shapes become obsolete and need to be changed in order for the
application to work. For me, it is no problem to update the Visio stencil
where all shapes originate from. But, is there a way to make changes to the
stencil automatically apply to shapes drawn in the Visio document?

/Mats-Lennart
 
C

Chris Roth [ Visio MVP ]

You have 5000 shapes. That is a LOT of data. And each shape has a little
spreadsheet engine behind it that enables smart behavior. It's not just a
clip art server.

If you go to XML, your document load time will probably just skyrocket
instead.

If your shapes are dumb, that is, they are only graphics that don't do
anything, you might experiment with making them metafiles.

But your major problem is simply having a large amount of data.

--

Hope this helps,

Chris Roth
Visio MVP
 
D

David Parker [Visio MVP]

You didn't say if you are using master-shape instances or not.
If so , are you using DropMany & SetFormulas?
 
M

Mats-Lennart Hansson

I have saved a large Visio document containing 100 pages with about 5000
shapes in total in XML format (.vdx) simply using File -> Save as. There
were no problems opening the document afterwards. 5000 shapes is a lot, but
I still think that the Visio OM has very poor performance in this case. I
think that if I can create an XML structure instead of importing shapes from
a stencil using the OM, this will be much faster. What do you think?

If I decide to go with XML I have to deduce the XML format for all of my
shapes. Many of the shapes are quite complex, containing varying amount of
subshapes etc. With this in mind, do you think it is a good idea to try to
deduce the XML format or will it simply be too complex to handle?

/Mats-Lennart
 
M

Mats-Lennart Hansson

When importing shapes we use a stencil as the source, so yes, we use master
shape instances. We use the DropMany function but not SetFormulas. In what
way do you think SetFormulas can increase the performance for us?

Thanks,

Mats-Lennart
 
C

Chris Roth [ Visio MVP ]

Another idea:

Are you running an .EXE or VBA or an add-in/on?

If you use VBA or a COM Add-in, then your code will run in-process and be up
to 3 times faster than an .EXE that has to marshal across boundaries.

--

Hope this helps,

Chris Roth
Visio MVP
 
M

Mats-Lennart Hansson

Thanks for you answer, I'm using a COM Add-in written in C#.

/Mats-Lennart
 
D

David Parker [Visio MVP]

Passing an array of shapes, SRCs and values to SetFormulas will work much
quicker than looping through each property on each shape.
 
M

Mark Nelson [MS]

There have already been several good suggestions on this thread, but I have
a few more.

First, loading a 5000 shape XML drawing will be much faster than generating
a 5000 shape drawing through the object model. The question is how fast can
you create that XML, and how complicated will that task be compared to using
the object model? I don't know the answer to that. You would have to
experiment.

Second, managed code will run slower with Visio than unmanaged code. There
is an extra step in the interface between your app and Visio. Also when
working with large documents, unmanaged code allows Visio to be more
economical with memory. Objects don't hang around as long after you are
done with them. It's difficult to quantify this difference, but I can
imagine it being a factor with large drawings.

Third, I want to emphasize how important it is to use SetFormulas instead of
SetFormula whenever you have to set more than one cell in a shape. Setting
a formula in a cell is an expensive operation compared to most other OM
properties and methods. SetFormulas lets you make all your changes with one
operation. It is basically twice as fast as SetFormula on two cells, four
times as fast as SetFormula on four cells, etc. The overhead in your code
to set up the cell array is minimal in comparison.

Fourth, whenever someone says that they have groups with sub-shapes, I ask
them whether they can reduce the number of sub-shapes. Typically you can.
You only need a sub-shape when you need an extra piece of text or an extra
set of format properties. You do not need sub-shapes for extra geometry.
Also make sure that you do not have groups within groups. Where possible,
put text and geometry on the group shape itself. This often saves you one
sub-shape.

--
Mark Nelson
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top