Page 3 of 3 FirstFirst 123
Results 81 to 87 of 87

Thread: Simple and fast, lightweight HashList-Class (no APIs)

  1. #81
    PowerPoster
    Join Date
    Jan 2020
    Posts
    5,538

    Re: Simple and fast, lightweight HashList-Class (no APIs)

    Originally, I just asked a simple question.
    In the previous example, the primary key is a string, and the data is: integer
    My usage is: primary key: value, the data is also a value, how to optimize it better, or how to change the source code of this dictionary object, because many people will not change it.
    Then adding or querying the primary key is:
    add(key as long, value as long)
    add(byval key as long, value as long)
    Which is faster, I just asked 2 sentences, and you guys responded with hundreds of words, but did not solve the actual problem.

    I hope there will be no war in the world, no atomic bombs, no missiles.
    Of course, everyone can discuss technical issues on the forum, but it should not be so intense.

    at #75,you say , can you write a new class for this?
    so i finished in #78.

    I would have expected someone more professional to implement this class module with a simple modification
    Since I'm not familiar with dictionary objects, modification takes hours.
    Last edited by xiaoyao; Jun 21st, 2023 at 04:01 AM.

  2. #82

    Thread Starter
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,454

    Re: Simple and fast, lightweight HashList-Class (no APIs)

    Quote Originally Posted by xiaoyao View Post
    Originally, I just asked a simple question.
    In the previous example, the primary key is a string, and the data is: integer
    My usage is: primary key: value, the data is also a value, how to optimize it better, or how to change the source code of this dictionary object, because many people will not change it.
    Then adding or querying the primary key is:
    add(key as long, value as long)
    add(byval key as long, value as long)
    Which is faster, I just asked 2 sentences, and you guys responded with hundreds of words, but did not solve the actual problem.
    My hints for you in #75 were comparably short (21 words).
    It's you who's producing spam-postings with hundreds of words (which don't belong into this discussion-topic here).

    Please inform yourself, about the purpose of "discussion-topics in the CodeBank" first
    (before you start typing, placing your unrelated nonsense, in threads where it does not belong)

    Quote Originally Posted by xiaoyao View Post
    I hope there will be no war in the world, no atomic bombs, no missiles.
    Of course, everyone can discuss technical issues on the forum, but it should not be so intense.
    Your obsession with "war and atomic-bombs" aside,
    please allow me to be "intense", whilst pointing out your "rude, spamming behaviour" here.

    Quote Originally Posted by xiaoyao View Post
    at #75,you say , can you write a new class for this?
    so i finished in #78.
    #78 did neither answer your own question -
    nor has it anything to do with cHashD (which is the topic of this discussion-thread).

    Olaf

  3. #83
    PowerPoster
    Join Date
    Jan 2020
    Posts
    5,538

    Re: Simple and fast, lightweight HashList-Class (no APIs)

    Because this topic itself is about discussing lightweight dictionary objects. The code is small enough, but not everyone has the ability to change what they need. In the end, it took me a few hours to complete it.
    I just had a question at the beginning, why getpropA can only execute 20,000 times a second, but the Dictionary object can read the key value 2 million times a second, and the speed difference is 100 times. I have doubts about the problem, so I studied it for a while.
    If I don't make it clear about the specific usage scenarios, it is definitely not appropriate.
    The actual situation is that I only use it to read 2 data, and the maximum number does not exceed 50.
    For the case of using 1000, 100,000 key values, some objects may be faster.

    So my question is actually, which dictionary object is faster to use when only a small amount of data is required to be queried?
    Finally, I changed the dictionary object that supports dozens of different data types to only support integer types. This code still has 324 lines.
    In the end, I changed a dictionary object with only about 30 lines.

  4. #84

    Thread Starter
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,454

    Re: Simple and fast, lightweight HashList-Class (no APIs)

    Quote Originally Posted by xiaoyao View Post
    The actual situation is that I only use it to read 2 data, and the maximum number does not exceed 50.
    Again, this is not the right place for you to "think out loud" (beginner-style, in bad english).

    It goes without saying, that "finding the index among Long-Values, with max 50 entries", performs best, when done:
    - via brute force, against a normal VB-LongArray with 50 slots
    - using a FindIndexForValue-function, placed in a *.bas-Module

    But nothing of that has anything to do, with the universally usable Class-encapsulation of cHashD (which this thread is dedicated to).

    Please move your "musings, and findings" whilst "learning to program" into the Main-Forum please.

    Olaf

  5. #85
    PowerPoster
    Join Date
    Jan 2020
    Posts
    5,538

    Re: Simple and fast, lightweight HashList-Class (no APIs)

    I just need a faster object for reading few properties. Perhaps properties such as HASHTABLE"CalcHash(key) as long" are not used at all.

    I only need to read an array of 10 data in a loop to find out which row is eligible, but its usage is the same as that of a dictionary, and it also needs ADD, GETITEM, Remove

    I just don't understand why Microsoft's Dictionary, which supports dozens of data types, can still maintain 2 million calls per second when there are only 10 data types.
    But VBA.Collection only has 300,000 times.
    cHashD2 IS 350,000 times.
    Last edited by xiaoyao; Jun 21st, 2023 at 02:04 PM.

  6. #86

    Thread Starter
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,454

    Re: Simple and fast, lightweight HashList-Class (no APIs)

    Quote Originally Posted by xiaoyao View Post
    I just need a faster object for reading few properties.
    No, you don't -
    and I will consider you a beginner, as long as you do not understand the meaning of "No, you don't" (in that context).

    Also, the results of your performance-comparisons are misleading (probably because you did not compile to native code, all options checked).
    Just played that through with the cHashD-implementation as posted in #30 here -
    and with Long-Values as Keys, cHashD (in a small set of 50 entries) is only about factor 2 slower than the MS-Dictionary (not factor 5-6 as you claimed).

    So again, please stop posting so much non-sensical or misleading information here.

    Olaf

  7. #87
    PowerPoster
    Join Date
    Jan 2020
    Posts
    5,538

    Re: Simple and fast, lightweight HashList-Class (no APIs)

    Ok,sorry,I TEST IN VB6 IDE,

    Compile it into EXE to run faster (and set various optimizations), and the power mode of the computer must be turned on to high performance, so that the comparison speed can be objective.
    At the same time, my test does not represent the actual performance of the components. Everyone should test on their own computer. The running speed of WIN7 and WIN10 may be quite different.

    GetArrHwnd in ide :2 million times per second
    GetArrHwnd in Exe :5 million times per second
    my test not like this:
    Code:
    for  i 1 to 1000
       m_OldProc = GetArrHwnd(Hwnd)
    next
    Code:
    Private Function ControlCallBack(ByVal Hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
            '---------------------------------
            QueryPerformanceCounter C1
    
            Dim m_OldProc As Long
            m_OldProc = GetArrHwnd(Hwnd)
    
            QueryPerformanceCounter C2
            '---------------------------------
            AllUsedTime = C2 - C1 + AllUsedTime
            MsgCount = MsgCount + 1
    
           ControlCallBack = CallWindowProc(m_OldProc, Hwnd, Msg, wParam, lParam)
    end function
    Code:
    Private Function GetArrHwnd(ByVal Hwnd As Long) As Long
    Dim i As Long
    For i = 0 To HookCount
        If ArrHwnd(i) = Hwnd Then
            GetArrHwnd = ArrOldProc(i)
            Exit For
        End If
    Next
    End Function
    I added 20 subclasses of controls and ended up with about the same speed. That's all for this topic.
    I'm sorry for misleading you.
    Last edited by xiaoyao; Jun 21st, 2023 at 03:48 PM.

Page 3 of 3 FirstFirst 123

Posting Permissions

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



Click Here to Expand Forum to Full Width