Shape creation slow

Started by daihashi, August 27, 2014, 12:37:07 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

daihashi

I hate coming here when I have a problem/challenge.. I would much rather post because I have something incredible to contribute, but alas here I am again.

Due to various reasons; primarily to keep file size as small as possible, I have a document I am creating that generates various "stencils" based on a couple of very simple boxes that act as my master. In nearly all my shapes this isn't a problem; the time to draw most of them only takes about 2-3 seconds... could be better but this is acceptable considering how much of this I am doing through code.

However, there are a few "stencils" that I attempt to draw via VBA and they are pretty darn slow; even more frustrating, the slowness only happens on the corporate issued laptops... but not on my personal workstation at home (isn't that always the case?? It seems that companies love to kill the performance of the computers that they issue their employees).

To create one of these "stencils", a total of 60+ shapes are dropped... most of them the exact same shape. Initially it took about 45 seconds to create this shape on my corporate laptop; I then started using the dropmany method instead and this improved performance drastically, reducing the total time to 25 seconds.. which is still too slow. I then implemented the setformulas method and this further reduced it to 19 seconds on the corporate laptop.. better but still too slow. I've gone through the sub routine and changed a number of array data types to be integer instead of variant, and wrote out the arrays in a long format. I tried to remove duplicate calculations when possible. I even tried using doevents, and even tried manipulating the GetQueueStatus API to try to further reduce the size, but this did not improve or decrease the performance of the document.

Keep in mind that this may run very quickly if you are using a personal workstation with an SSD hard drive. If you have an older PC, or a corporate laptop that is heavily loaded with the typical windows 7 image and things like McAfee suite, then perhaps you will be able to replicate the slowness... I sure hope so, because I just can't seem to figure this problem out.

I would simply make the entire thing as a pre-made master... which is lightning fast, but this drastically increases the file size and our documents can be very detailed and have many pages, so keeping the file size as small as possible; even if it only saves a few kb per shape, is important to me.

daihashi

I forgot to include the files.

Copy SMART[MASTERS]2.vss to your C:\temp directory, and then open "help[sadface].vsd".

When the document opens, right click on the second grouped shape from the top and select "Add Video Conferencing". This will add the shape that I am having problems with.  The code for this shape can be found inside the SMART[MASTERS]2.vss file. I removed as much of the code as possible. Currently the "real" document I have is about 80k lines of code, but only because I haven't gone back and re-written most of my subs/functions into arrays and loops yet; I always write things out in long format before I finalize the code.

This version has substantially less; so many of the buttons and functions you see in the document won't work properly.. however, the "Add Video Conferencing" will work... which is all I care about.

There are 3 different subs, the first one is called "ADD_SERVICE_VC3"; this calls another sub called "service_formulas", and then after that "ADD_TABLE_VC3" is called. It is this last sub where all the heavy work is done, and also where the slowness occurs. Again, on my workstation at home this only takes about 3 seconds to add... but on my corporate laptop it currently takes about 19 seconds; which is far too slow to be usable.

daihashi

Darn.. the files are slightly too big even though I stripped out most of the code and unused master shapes. I've provided a google drive link to the files instead.

Here is a link to the file named SMART[MASTERS]2.vss
https://drive.google.com/file/d/0B9b6fB8CncnQbDBPeGh3UWZtQXM/edit?usp=sharing

Here is the link to the file named help_[sadface]2.vsd:
https://drive.google.com/file/d/0B9b6fB8CncnQanZneGpKYUtCVzg/edit?usp=sharing

daihashi

I should note... probably the only thing I haven't done is consolidate the several dropmany and setformula loops that I have. Based on my current experience though... I don't see this saving me much more than 1-2 extra seconds at best.

I will give this a try tomorrow; hopefully I'm wrong and it speeds things up exponentially.

Yacine

Hi Daihashi,
that's already pretty hardcore stuff. I'm impressed.
And the listed measures to speed up the code cover so mainly all what I've ever heard or read of. Nice job.
I couldn't get your code to run, so that I can't give any precise observation.

Just some thoughts however and for whatever they may help.


       
  • If there's this significant speed difference between private and business configuration, it suggests that the speed problem is rather to be found in some I/O operations - either between files or applications/dlls. There shouldn't be that big difference in simple internal visio operations.
  • Are there different office versions installed on private/business computers? I saw that you consider 32 and 64 bit systems.
  • You may analyse systematically the duration of your routines. (http://stackoverflow.com/questions/198409/how-do-you-test-running-time-of-vba-code)
Regards,
Yacine

AndyW

I've just downloaded and tried this (Visio 2010/Windows 7 64 bit, Intel Core 2 Duo CPU E6850 @ 3GHz, 2GB memory), takes 1 second.

Had trouble with your string Replace of "in." as it is only "in" on my machine. You would be better using the ResultIU (internal units - which is always in inches) rather than ResultStr.
Live life with an open mind

daihashi

Quote from: AndyW on August 27, 2014, 10:35:23 AM
I've just downloaded and tried this (Visio 2010/Windows 7 64 bit, Intel Core 2 Duo CPU E6850 @ 3GHz, 2GB memory), takes 1 second.

Had trouble with your string Replace of "in." as it is only "in" on my machine. You would be better using the ResultIU (internal units - which is always in inches) rather than ResultStr.

thanks for the feedback on the replace string... and also trying it out.

I finally got some feedback from one of co-workers who I asked to test it. I placed several timers to cover each of the dropmany/setformula loops, and it seems that it might be isolated only to my laptop. This is both funny to me and frustrating. Funny because I've always suspected something was wrong with my corporate issued laptop, and frustrating for the exact same reason.

Hopefully my other co-workers will report that this works fine for them as well, and this post will actually end up being a non-issue.

Thanks again for the feedback!

AndyW

I have seen corporate PCs perform very poorly with Visio where McAfee is used. Can you disable (or have it temporarily disabled) and see if that improves things.
Live life with an open mind

daihashi

Quote from: Yacine on August 27, 2014, 06:54:27 AM
Hi Daihashi,
that's already pretty hardcore stuff. I'm impressed.
And the listed measures to speed up the code cover so mainly all what I've ever heard or read of. Nice job.
I couldn't get your code to run, so that I can't give any precise observation.

Just some thoughts however and for whatever they may help.


       
  • If there's this significant speed difference between private and business configuration, it suggests that the speed problem is rather to be found in some I/O operations - either between files or applications/dlls. There shouldn't be that big difference in simple internal visio operations.
  • Are there different office versions installed on private/business computers? I saw that you consider 32 and 64 bit systems.
  • You may analyse systematically the duration of your routines. (http://stackoverflow.com/questions/198409/how-do-you-test-running-time-of-vba-code)
Regards,

Thanks Yacine; a compliment from you means a great deal to me considering the large body of knowledge you have.

To answer some of your questions:

  • It seems that the problem may simply be isolated to my computer. I placed several timers in the code and sent it to my co-workers; they don't experience the delay that I do. It's a relief that it's isolated to my computer.
  • Unfortunately yes; I wish I could have included the full code, but the download would have been much larger. In my code, upon document open, it detects whether a person is using Office 2013, Office 2010, or 2007 and earlier, and it adjusts it's code accordingly. It also will detect between 64bit and 32 bit; the last part I wrote mostly for myself since I use 32bit at my job, and 64 bit on my home workstation. The code probably would have ran properly for you if I had left the "office detection" bits in the vss file. sorry about that :(
  • Yes, I have actual timers in my test document. I stripped them out because I didn't want to annoy anyone here who was kind enough to test my code. The methods I used was GetTickCount, and I also used a more simplistic starttime=now and endtime=now method. This is how I was able to narrow down specifically where I was experiencing slowness; which now seems to be isolated to my PC only (pending further validations... if so then thank goodness, I've been beating my head against the wall to try to get this to go faster :)
>
[/list]

Thanks again Yacine; your compliment has really made my day since I still consider myself a novice. This just encourages me to work harder and learn even more. :)

daihashi

Quote from: AndyW on August 27, 2014, 02:10:07 PM
I have seen corporate PCs perform very poorly with Visio where McAfee is used. Can you disable (or have it temporarily disabled) and see if that improves things.

Trust me, I wish I could but the system is "locked down". I can crack the local admin password on the computer, but then that breaks it's ability for the machine to join the domain. It seems that the domain somehow uses the local admin account to validate the machine certificate; although I'm not sure why they did it this way.

Yacine

#10
QuoteThanks again Yacine; your compliment has really made my day since I still consider myself a novice. This just encourages me to work harder and learn even more.

Hi Daihashi,
I honestly confess that I feel flattered, but not only is your compliment embarassing, but also not justified.
The fact that I post so often is only due to my addiction to visio, not my "knowledge" or "expertise".
Compared to the "first generation members", I actually do consider myself as novice too.

At some time I realised that all these champions are actually very speciallised and that if you are lucky enough to get a task that challenges you enough , you can master a certain domain visio (devotion required).

There are these fabolous guys here, like Paul as specialist in addons written in Pascal and trouble shooting of all kind, Wapperdude with its deep shapesheet knowledge, June with his Geometry magic, Al Edlund with his Databases and Racks, the big coding slavic fraction with Nikolay, Surrogate, and much more. Even some book authors like Chris (the Visio Guy), or John Goldsmith. But all of them are specialised in a certain area of Visio.

I wish you good luck in your "visio career". I think you found already your specialisation.  ;)
Yacine

daihashi

Well.. I won't argue with you; I'll simply state that in comparison to you (and of course others), I am a novice. Also, it's almost not fair to try to compare yourself to the people you mentioned. I hope to one day be as good as some of them, but their skill is so far from my current abilities that they seem almost god like.

I gain quite a bit from your posts; I read many of them even though I don't participate in most threads. Your posts seem to always help me look at my own challenges in a different way, and allow me to see solutions that I originally did not realize upon first encountering them. Either way, I'm very appreciative to be on a forum like this... where I have access people like yourself, and others, who are so willing to help and share the knowledge that they have.

I am very glad that I found out about this forum. It is an amazing place. :)

Croc

I experienced Visio slow down in operations with the page when default printer was not available. It was attached to the computer that was turned off.
Maybe you have a similar reason.

daihashi

#13
Quote from: Croc on August 28, 2014, 06:20:27 PM
I experienced Visio slow down in operations with the page when default printer was not available. It was attached to the computer that was turned off.
Maybe you have a similar reason.

I'll load one of my older versions and try setting the default printer; although that seems a bit odd, but worth a shot.

Today another one of my co-workers experienced the same slowness that I did. So I decided to just make this a prebuilt shape; which obviously makes it very fast. If the default printer idea that Croc posted works then I'll go back to my previous method; if it does not then I will stick with the prebuilt shape for now. I wish I had more time to resolve this programmatically, but I've used up too much time on this one problem, and I'm already past due for this quarter's template release. :(

update: one thing that is interesting to note. The individual who experienced no slowness was using visio 2010, and the person who had the same results as me was using visio 2013 (which I am also using). I wonder if visio 2010 was more efficient with this code for some reason.

daihashi

Oh, I forgot to mention. If anyone is curious and wants to know what the depth of automation my real template has, take a look at the documentsheet, pagesheet, and any hidden pages (UIvisibility=1) pagesheets that might be there. Some of the stuff you'll see is brute force, but I think I might have a few clever things in there that might be useful to some people. You can also look at the shapesheet formulas. I use the various sheets very heavily.

This document excerpt that I posted here is what I jokingly refer to as a "Network engineer in a box", because it can generate a number of solutions very easily, and automate most aspects of the documentation with minimal (to almost no) input required from the user. It bases the solutions around current approved standards, however since I keep all the code in the stencil file.. I have control of keeping all documents accurate. Upon document open the template makes a call to my server to see if there is an update available, if so it downloads the new stencil file. It will also make a call to the server if it sees the file doesn't exist.

The server backend is utilized very heavily, and actually allows documents to be aware of data in other documents... and alert the user about it immediately. So not only does it automate much of the documentation, but it also error/conflict checks across all other documents that use this template.

There's much much more to this, but I don't want to sound as if I'm bragging. I simply get very excited when I think of how I can help everyone around me through the power of automation, and then we can refocus that time that is saved on innovating new solutions. Visio is pretty awesome. :)