[Libreoffice-bugs] [Bug 129256] New: ReDim is slow when array custom type is explicitly known
bugzilla-daemon at bugs.documentfoundation.org
bugzilla-daemon at bugs.documentfoundation.org
Sat Dec 7 08:23:54 UTC 2019
https://bugs.documentfoundation.org/show_bug.cgi?id=129256
Bug ID: 129256
Summary: ReDim is slow when array custom type is explicitly
known
Product: LibreOffice
Version: unspecified
Hardware: All
OS: All
Status: UNCONFIRMED
Keywords: perf
Severity: normal
Priority: medium
Component: BASIC
Assignee: libreoffice-bugs at lists.freedesktop.org
Reporter: mikekaganski at hotmail.com
With this code:
> Type TCustomType
> m_arr(20) As Long
> m_str As String
> End Type
>
> Sub CustomReDim1(ByRef A() As TCustomType, newU As Long)
> ReDim Preserve A(newU)
> End Sub
>
> Sub CustomReDim2(ByRef A(), newU As Long)
> Dim oldU As Long, emptyVal As TCustomType, i As Long
> oldU = UBound(A)
> ReDim Preserve A(newU)
> For i = oldU + 1 To newU
> A(i) = emptyVal
> Next i
> End Sub
>
> Sub ReDimTest
> Dim A1(0) As TCustomType, A2(0) As TCustomType, A3(0) As TCustomType, time1 As Date, i As Long, msg As String
> time1 = Now()
> Const maxIter = 2000
> For i = 1 To maxIter
> ReDim Preserve A1(i)
> Next i
> msg = "Testing ReDim Preserve: " & Format(now() - time1, "[s]"" s""") & Chr(13)
> time1 = Now()
> For i = 1 To maxIter
> CustomReDim1(A2, i)
> Next i
> msg = msg & "Testing CustomReDim1: " & Format(now() - time1, "[s]"" s""") & Chr(13)
> time1 = Now()
> For i = 1 To maxIter
> CustomReDim2(A3, i)
> Next i
> MsgBox msg & "Testing CustomReDim2: " & Format(now() - time1, "[s]"" s""")
> End Sub
I get this on current master Version: 6.5.0.0.alpha0+ (x64)
Build ID: 08615ce879927bc58924e9591985f27fe59a11fa
CPU threads: 12; OS: Windows 10.0 Build 18363; UI render: Skia/Raster; VCL:
win;
Locale: ru-RU (ru_RU); UI-Language: en-US
Calc: CL
44 s
44 s
5 s
See how much faster the result is when ReDim gets an array without the element
type known in the function, and then assigning an empty value as it would
happen when the type is known.
Of course, that is debug version, and thus slow, but it shows how inefficient
the ReDim is for custom types, and in the same time, it can be much more
efficient if ReDim doesn't know the custom type - still providing the same end
result.
The code is affected by tdf#129227, so it would result in even greater
difference in releases 5.3 to 6.3.3, so better test in master with the
mentioned bug fixed. Note that the problem discussed in this issue was present
in to v.5.2 and older.
--
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/libreoffice-bugs/attachments/20191207/93cc4e4a/attachment-0001.html>
More information about the Libreoffice-bugs
mailing list