Which one is faster catvba, CATScript, CATVBS or VB.net ?

Vishal Gawali, Mr

Which one is faster catvba, CATScript, CATVBS or VB.net ?

Hi All,

I am comparing the COGs of surfaces of two parts .
The steps are to get the surfaces of each part.
Get their COGs and compare their COGs.
Time matters when there are large number of surfaces.
We did it first in catvba.
Then we shifted to VB.net
and then tested on CATScript and CATVBS.

Below are the timings for the same number of surfaces.

catvba 4 sec
CATVBS 54 sec
CatScript 50 sec
VB.NET 213 sec


catvba has been the fastest so far.
I had heard that VB.net is faster.Is it ?
Am I missing something in VB.net ?

Regards

 

-

Little Cthulhu

RE: Which one is faster catvba, CATScript, CATVBS or VB.net ?
(in response to Vishal Gawali, Mr)

All languages that you've mentioned use the same set of APIs called Automation. So time spent on actual API code is going to be identical.

However, Automation interfaces are COM-based and a decent amount of work should be done before performing that API call.

 

With that being said, running identically well-optimized code (post your catvba and CATScript by the way)  is going to give you following rankings:

1. CATScript = CATVbs (CATIA replaces "extra" code and treats CATScript as vbscript)

2. catvba

3. VB.NET

There's little to no overhead on working with Automation interfaces in CATScript compared to VB.NET, which suffers immeasurably of CLR to COM marshaling.

CATVBA requires VBA editor to be initialized and runs in debuggable manner which cost perfomance.

Thomas J Vanderwiel, Tooling KBE Engineer

RE: Which one is faster catvba, CATScript, CATVBS or VB.net ?
(in response to Little Cthulhu)


VBA is the fastest option but it does not need to be used by itself.  I can be called from .NET and only return the values it collects.  If you avoid collecting and sending objects back to .NET, you avoid a lot of COM overhead and can use all of the .NET UI functionality as well as run other COM type processes such as outputting to Excel.

TomV

Boeing

Little Cthulhu

RE: Which one is faster catvba, CATScript, CATVBS or VB.net ?
(in response to Thomas J Vanderwiel, Tooling KBE Engineer)

What kind of scenario are you talking about Thomas?

I've performed thousands of tests in dozens of scenarios and never, not a single time VBA was able to come close to CATScript. It was always 10-100 times slower.

When testing I focused on assembly design, structure and systems workshops.

One thing to note is that VBA is set up to run out of process (in it's own CATVBAHostingApplication.exe 32-bit process) to enable all of Microsoft's legacy UI components.

How do you run your VBA? What scenarios are you referring to? Can you post a sample code?

Edited By:
Little Cthulhu[Subscriber Members] @ Jan 19, 2023 - 09:15 AM (Europe/Moscow)

Thomas J Vanderwiel, Tooling KBE Engineer

RE: Which one is faster catvba, CATScript, CATVBS or VB.net ?
(in response to Little Cthulhu)

The simple code below traverses the product tree.  The results are from running it using VBA, EKL VB Script, CATScript and MS VBScript.  The test product has 35473 nodes. VBA runs in process and is compiled/tokenized to execute more efficiently than interpreting the text line by line.

 

When running scripts from .NET it is always best to avoid sending objects back to .NET to avoid boxing and unboxing COM objects. But in .NET you can run CATIA processes in parallel which cannot be done in any of the scripting frameworks.

 

Sub CollectProdObjIds_Test1()
Dim st As Single
Dim et As Single
st = Timer
Dim dic1 As Dictionary
Set dic1 = CreateObject("Scripting.Dictionary")
CollectProdObjIds CATIA.ActiveDocument.Product, dic1, "1"
et = Timer
Debug.Print "' VBA: " & et - st & " Ct: " & dic1.Count

' Product Ct: 35473
' ===================
' VBA:
' -----
' 0.2792969
' 0.2871094
' 0.2929688

' EKL VB Script:
' --------------
' 0.8564612
' 0.8398438
' 0.8554688

' CATScript:
' ----------
' 0.8066406
' 0.8984375
' 0.8652344

' MS VBScript:
' ------------
' 0.7265625
' 0.7460938
' 0.7187500

End Sub

Sub CollectProdObjIds(prod1 As Product, dic1 As Dictionary, k1 As String)
Dim prod2 As Product
Dim i As Long
Dim k2 As String
dic1.Add k1, prod1.Name
i = 0
For Each prod2 In prod1.Products
i = i + 1
k2 = k1 & "." & i
Call CollectProdObjIds(prod2, dic1, k2)
Next
End Sub

TomV

Boeing

Edited By:
Thomas J Vanderwiel, Tooling KBE Engineer[The Boeing Company] @ Jan 19, 2023 - 08:33 AM (America/Pacific)

Little Cthulhu

RE: Which one is faster catvba, CATScript, CATVBS or VB.net ?
(in response to Thomas J Vanderwiel, Tooling KBE Engineer)

Thanks for the sample code. Tested it on R25 SP3:

- CATScript - 0.7s

- VBA 32-bit (out of proc) - 33s

- VBA 64-bit - 0.25s

Out of process 32-bit VBA is 100 times slower than 64-bit!

We have been using VBA for simple UI when it's not reasonable to develop .NET standalone application. All macro code is written in CATScript with shared code placed in reusable WSC components. 

I guess now we have to eliminate legacy microsoft UI components and switch to 64-bit VBA completely.

Thanks again, Thomas!

Thomas J Vanderwiel, Tooling KBE Engineer

RE: Which one is faster catvba, CATScript, CATVBS or VB.net ?
(in response to Little Cthulhu)

Why are you running VBA out of process when it naturally runs in process?  That's comparable to running VB.NET

TomV

Boeing

Little Cthulhu

RE: Which one is faster catvba, CATScript, CATVBS or VB.net ?
(in response to Thomas J Vanderwiel, Tooling KBE Engineer)

Back in 32-bit days most of our CATIA applications was written in VBA. Since those apps were relatively complex we used many ActiveX components, including Microsoft Common Controls.

Then 64-bit CATIA came along with 64-bit VBA and all apps became unlaunchable. Microsoft stated that they were not going to support 64-bit versions of their components so we had to force CATIA to launch VBA as 32-bit process. At the same time we started migrating to .NET.

So we never had a chance to compare perfomance of 32-bit and 64-bit versions of VBA because latter was not an option for us.