Page 2 of 6 FirstFirst 1234 ... LastLast
Results 11 to 20 of 52

Thread: ARRAY-ideas

  1. #11
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10
    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
    Attached Files Attached Files
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  2. #12
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Germany
    Age
    54
    Posts
    1,530
    Rep Power
    171
    here it works - and tB becomes better and better
    I think there are missing some Forum-sections as beta-testing and support

  3. #13
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732
    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
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  4. #14
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Germany
    Age
    54
    Posts
    1,530
    Rep Power
    171
    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
    Last edited by ReneMiner; 11-09-2014 at 07:47.
    I think there are missing some Forum-sections as beta-testing and support

  5. #15
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10
    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
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  6. #16
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Germany
    Age
    54
    Posts
    1,530
    Rep Power
    171
    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.
    Attached Images Attached Images
    Last edited by ReneMiner; 11-09-2014 at 07:58.
    I think there are missing some Forum-sections as beta-testing and support

  7. #17
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Germany
    Age
    54
    Posts
    1,530
    Rep Power
    171

    some speed-test for the new array-scan-ptr

    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 )
    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
    
    (you may comment lines 30 & 47 to subtract the printing-time)

    Results may differ due randomized values to check for, but the felt average on my system = 1.0 / 5.5
    Attached Images Attached Images
    Last edited by ReneMiner; 12-09-2014 at 10:58.
    I think there are missing some Forum-sections as beta-testing and support

  8. #18
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10
    mmmmm

    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.

    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  9. #19
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10
    Dear Rene,

    can you please check the attached new thinBasic Core engine and see new speed in ARRAY SCAN ... PTR ... ?

    Attached Files Attached Files
    Last edited by ErosOlmi; 12-09-2014 at 22:48.
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  10. #20
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Germany
    Age
    54
    Posts
    1,530
    Rep Power
    171

    new thinCore.dll leads to crash

    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...()
    Attached Images Attached Images
    Last edited by ReneMiner; 13-09-2014 at 12:21.
    I think there are missing some Forum-sections as beta-testing and support

Page 2 of 6 FirstFirst 1234 ... LastLast

Similar Threads

  1. OOP ideas
    By ErosOlmi in forum Suggestions/Ideas discussions
    Replies: 13
    Last Post: 26-08-2013, 20:26
  2. Ideas for dynamic Array-constructor on the fly
    By ReneMiner in forum Suggestions/Ideas discussions
    Replies: 0
    Last Post: 16-07-2013, 08:53
  3. copy array of UDT to another array in one step?
    By ReneMiner in forum thinBasic General
    Replies: 3
    Last Post: 02-11-2012, 01:15
  4. More Ideas
    By peter in forum Sources, Templates, Code Snippets, Tips and Tricks, Do you know ...
    Replies: 3
    Last Post: 27-10-2012, 14:47

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •