OK, I could not resist!
It was like I expected.
Please find here attached a new thinCore.dll
Let me know if it works.
Ciao
Eros
Printable View
OK, I could not resist!
It was like I expected.
Please find here attached a new thinCore.dll
Let me know if it works.
Ciao
Eros
here it works - and tB becomes better and better :)
Hehe,
Eros at his best :) Great!
I have one suggestion regarding syntactic sugar. To keep in line with Dim..At, SetAt, GetAt...
What about changing the syntax of "ARRAY SCAN pointerToMemory PTR" to "ARRAY SCAN AT pointerToMemory"?
Petr
Hi Petr, i think At is more like sign for an absolute variable while Array Scan myArray Ptr can be a real or some virtual array so At would be a little confusing while Ptr just tells Array Scan that its an array of pointers that point the data to scan.
The reason why you thought this might be because the above examples use as less real variables as necessary since they need time to Dim and allocate space. I'm convinced an overlay at some existing data is always the way to prefer when it comes to fast script execution
Ciao Petr,
I thought about that but here "pointerToMemory" is not a pointer to memory but an array variable from which ARRAY SCAN detect array variable type an array number of elements without which it would be impossible to perform the scan. So I used PTR after array name to tell that DWORD array is a DWORD array of pointer allocated by HEAP_AllocByStr and not just other generic allocation method. Knowing that, I can use HEAP functionalities to detect real memory area and length of the allocated memory.
So ... It is a very specific ARRAY SCAN
Maybe I can add HEAP keyword in order to clarify it better. Something like ARRAY SCAN HEAP myDWordArray ...
Sent from my iPhone using Tapatalk
Eros I think Ptr-keyword is fine just for this one usage here. It were something else if Heap would be a keyword already but since it's not i would refrain from adding a keyword here.
some speedtest to compare the way i used before and now ... and i'm happy about the result,
now needs around 15% to 20% of the time it needed before to find a certain element:
#MinVersion 1.9.13.0 + new thinCore.dll ( attachement a few posts above )
(you may comment lines 30 & 47 to subtract the printing-time)Code:Uses "console"
' heap-scan-speedtest
Function TBMain()
Local myPtr(&H4000) As DWord
Local i, j As Long
Local startingTime, neededTime As Quad
Local sToFind As String
Randomize
HiResTimer_Init
PrintL "filling in data now..."
For i = 1 To UBound(myPtr)
myPtr(i) = HEAP_AllocByStr("Mississippi" & Hex$(i,8))
Next
' - - - - - - - - - - - - - - - - - - -
PrintL "do 255 scans the old way:"
startingTime = HiResTimer_Get
For i = 1 To 255
sToFind = Ucase$("mississippi" & Hex$(Rnd(1, UBound(myPtr)), 8))
For j = 1 To UBound(myPtr)
If Ucase$(HEAP_Get(myPtr(j))) = sToFind Then
Print "." ' <<< if comment this then <<<
Exit For
EndIf
Next
Next
PrintL
neededTime = HiResTimer_Get - startingtime
PrintL "Time needed : " + Format$(neededTime / 1000000, "#.0000")
PrintL $CRLF & Repeat$(42, "_")
' - - - - - - - - - - - - - - - - - - -
PrintL "now 255 scans the new way:"
startingTime = HiResTimer_Get
For i = 1 To 255
sToFind = Ucase$("mississippi" & Hex$(Rnd(1, UBound(myPtr)), 8))
If Array Scan myPtr Ptr, Collate Ucase, = sToFind Then
Print "." ' <<< comment this too <<<
EndIf
Next
PrintL
neededTime = HiResTimer_Get - startingtime
PrintL "Time needed : " + Format$(neededTime / 1000000, "#.0000")
' - - - - - - - - - - - - - - - - - - -
PrintL $CRLF & Repeat$(42, "*")
PrintL $CRLF & "Any key to end"
WaitKey
End Function
Results may differ due randomized values to check for, but the felt average on my system = 1.0 / 5.5
mmmmm :grrrr:
I'm not happy about this speed difference: from 3.3 sec to 0.6 is not enough :)
I will see if I can improve it using your example.
:comp4:
Dear Rene,
can you please check the attached new thinBasic Core engine and see new speed in ARRAY SCAN ... PTR ... ?
:rolleyes:
when i tried out my current gui-project i discovered that tB instantly crashes on startup. i does not happen if i use the previous thincore-version.
Find array-scan-functions in unit-file GUI.tBasicU, all called like t_GUI.Enum...()