Description: More than 1000x > than Excel Steps to Reproduce: 1. Run the code in the other information section. 2. 3. Actual Results: 12 seconds for 10K WeekNum() calls (> 1ms per) More than 1000x > than Excel Expected Results: Reasonably close to Excel performance (< 10x) 0.101 seconds for 10K WeekNum() calls Reproducible: Always User Profile Reset: No Additional Info: Option VBASupport 1 Sub WeekNum_Function_Performance() Dim T1 As Single Dim T2 As Single With WorksheetFunction T1 = Timer() For i = 1 To 10000 WkNum = .WeekNum("03/14/2023", 1) Next i T2 = Timer() End With MsgBox ("Iterations: " & i & ", Time: " & T2 - T1) End Sub
VBASupport is a compatibility layer, so don't expect speed. Any invocation of WorksheetFunction.something() requires overhead that can't be neglected. You'd probably save some time using the com.sun.star.sheet.FunctionAccess service directly from BASIC. See https://api.libreoffice.org/docs/idl/ref/servicecom_1_1sun_1_1star_1_1sheet_1_1FunctionAccess.html
I realize VBA is a compatibility layer and do expect a performance hit. But a 1000 x performance hit? Seriously? Actually it even more the 1000 x because the system used for the Excel benchmark is 10 years old and much slower machine. 1.8GHz compared to 2.4GHz. The performance difference is probably near 2000 x. That doesn't seem reasonable even for compatibility. Even though it technically functions. With the much of a performance hit, it's essentially not compatible. Pretty sure there is plenty of room for improvement.