I am trying to benchmark in a reliable way SOLIDWORKS to compare some modification we perform on assembly components and measure their impact on performance. I am trying to get a macro running time using the timer function before and after I launch a command.
like this pseudocode
Code: Select all
starttime1 = timer
openfile(filename )
endtime1 = timer - starttime
starttime2 = timer
generatedrawing(filename)
endtime2 = timer - starttime
Sometimes I noticed the time recorded is just unreliable and could be off even 50+ seconds.
I am testing my VBA macro with a file that takes around 60s to fully load and 120s to generate 4 views in our drawing template.
For the drawing part I am aware that the view rebuild/update works in multithreading so my macro timer is probably going to stop well before the completion of the drawing and it is likely limited to SW main thread, leaving the view generation processes in background.
by mp3-250 » Tue Aug 27, 2024 5:25 am
I looked around the web and it seems the timer function is just low priority and in case the CPU is very busy it could lag behind.
It seems like my macro was asking the cpu too many things at once: I added some Doevents and the macro runs a lot smoother being able to begin a task before starying another.
E.g. when I inserted our drawing template the macro switched immediately to the main 3 views generation, but most of the time the screen was freezed on SW 3D: I noticed that in rare occasions the drawing sheet was visualized and the total running time was shorter.
I added a Doevents after inserting the template, in this way SW was able to "take a breath", switching to drafting mode, insert the template and, only at that time, starting the view generation tasks.
Go to full post