08-10-2012 09:13 AM
I just started evaluating the new 2012 edition and all my 2011 VBScripts seem to have severe speed issues especially involving automated Report creation. It became so slow, that it nearly doubles the runtime of my scripts. Is it a known issue?
Thanks for your help on this.
Phex
08-10-2012 12:25 PM
Here is a minimal example:
'===============================
R1 = TTR(CurrDateTime)
Dim iCount
For iCount = 1 To 200
Call GraphSheetNew(iCount)
Call GraphSheetShow(iCount)
Call GraphObjNew("2D-Axis", iCount)
Call GraphObjOpen(iCount)
Call GraphObjClose(iCount)
Call PicUpdate()
Next
R2 = TTR(CurrDateTime) - R1
Call LogFileWrite("Elapsed time: " & R2 & "s")
'===============================
It basically creates a series of report sheets, which is not the problem. The slow part is the GraphObjOpen and GraphObjClose.
I tested both on the same machine with exaclty the same screen configuration etc.
Result: 2012 = 11s, 2011 = 7s
What has changed?
08-11-2012 12:22 PM
Hi Phex,
I was not aware of this effect, but I have been able to reproduce it with your code-- I got 8s in 2011 and 12s in 2012 on my older laptop. What has changed is that DIAdem 2012 has a brand new Report object so that you can program the REPORT panel much easier and faster. I guess that new Report object added overhead that is slowing down the existing code. I recreated your code snippet with the new Report object in DIAdem 2012, and I was able to run the new code in 8s, about the same time as the red REPORT commands running in DIAdem 2011:
Call Report.NewLayout R1 = Timer Dim iCount For iCount = 1 To 200 Set Sheet = Report.Sheets.Add(iCount) Call Sheet.Activate Set Graph = Sheet.Objects.Add(eReportObject2DAxisSystem, iCount) Call Report.Refresh Next R2 = Timer T1 = "Elapsed time: " & str(R2-R1, "d.d") & "s" MsgBox T1
If I comment out the "Sheet.Activate" and the "Report.Refresh" commands, though, the code runs through in just over 2s, whereas commenting out the "GraphSheetShow" and "PicUpdate" commands in your code and running them in DIAdem 2011 still takes 4s because there is an inherent refresh in the "GraphSheetNew" command that you can't escape. If you want speed. I'd suggest using the new Report object and commenting out one or both of the refreshing command. If you want to see the sheets as they get created for user progress display, you can comment back in the "Sheet.Activate" command and still run through the code in 5.5s.
So in summary I'd say the new Report object gives you the ability to run your code much faster than before, and it's WAY easier to work with because of the intellisense you get in the SCRIPT editor-- give it a try!
Brad Turpin
DIAdem Product Support Engineer
National Instruments
08-11-2012 03:49 PM
Hi Brad,
thanks for your quick reply and your advice. I also waited for this report object a long time, though I do have quite a bunch of scripts utilizing the old style and some of them now take pretty much time with 2012 (yes, I need the user progress display). So I guess I will have to keep both versions running.
On the contrary I was just thinking if it were posible to write a script that transforms all my old scripts to the object type with a simple search and replace functionality. It might get a little tricky with the several levels of GraphObjOpen, but it should be feasible. What do you think?
Phex
08-13-2012 03:18 PM
Hi Phex,
Regarding the idea of a VBScript convert existing code from old stype report programming to the new Report object programming-- R&D decided not to attempt it, and neither have I. I agree that it doesn't sound like rocket science, but I'll bet the devil is in the details.
Brad Turpin
DIAdem Product Support Engineer
National Instruments