Announcement

Collapse
No announcement yet.

TYPE DirData; FileSizeHigh AS DWORD, FileSizeLow, AS DWORD

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    TYPE DirData; FileSizeHigh AS DWORD, FileSizeLow, AS DWORD

    I’m assuming those can be combined to get the Quad file size.
    Could someone please tell me how to combine to get the Quad file size?


    #2
    Code:
    MAK(QUAD, DD.FileSizeLow, DD.FileSizeHigh)
    In DIRDATA they are HIGH first, but Windows is little endian.

    (I do not know why MS did it backwards in DIRDATA)

    Cheers,
    Dale

    Comment


      #3
      thanks Dale Yarker

      Comment


        #4
        Or to quote MS documentation for WIN32_FIND_DATA:

        The size of the file is equal to (nFileSizeHigh * (MAXDWORD+1)) + nFileSizeLow.​
        ​or as used here: https://forum.powerbasic.com/forum/u...574#post826574

        4294967296 * ddat.filesizehigh + ddat.filesizelow

        which is roughly 5 times as fast as MAK(QUAD,,,,) in my testing

        Actually takes twice as long if you correctly use DWORD variables , not literals (as I did) in the test
        Last edited by Stuart McLachlan; 13 Sep 2023, 01:37 PM.
        =========================
        https://camcopng.com
        =========================

        Comment


          #5
          Thanks Stuart, Dale’s answer worked fine.
          I’m just not to up to speed on Hi/Lo.
          Should have paid the price a long time ago on Win32, now I suffer.
          I even got out Petzold and started studding. Might be too big a hill this late in the game.

          Comment


            #6
            'I don't see as more obvious. But is opinion
            'Is slower in any case.
            '
            Code:
            #compile exe 'in PBWin, or in PBCC without console
            #dim all
            #if %def(%pb_cc32)
              #console off
            #endif
            %UNICODE = 1
            type AbrevDirData
              filesizehigh as dword
              filesizelow as dword
            end type
            function pbmain () as long
              local ddat as AbrevDirData
              local FileTimeQd, TixCnt, TixCnt2 as quad
              local ForCnt as long
              local TWin as dword
              txt.window("compare 2 dwords to quad", 100, 100, 20, 45)  to TWin
              ddat.filesizehigh = 7
              ddat.filesizelow = 9
              tix TixCnt
              for ForCnt = 1 to 10000000
                FileTimeQd = 4294967296 * ddat.filesizehigh + ddat.filesizelow
              next
              tix end TixCnt
              txt.print dec$(TixCnt,11) + " multiply and add"
              '
              tix TixCnt2
              for ForCnt = 1 to 10000000
                FileTimeQd = mak(quad, ddat.FileSizeLow, ddat.FileSizeHigh)
              next
              tix end TixCnt2
              txt.print dec$(TixCnt2,11) + " MAK"
              txt.print
              txt.print str$(TixCnt / TixCnt2) + " ratio"
            '
              txt.waitkey$
              txt.end
            end function '
            Cheers,​
            Dale

            Comment


              #7
              Originally posted by Dale Yarker View Post
              'I don't see as more obvious. But is opinion
              'Is slower in any case.
              Interesting, I was testing with literals and got X5.

              You are correct when using DWORD variables instead, it is indeed slower.
              =========================
              https://camcopng.com
              =========================

              Comment


                #8
                And yours looks backward to me. Heck I got "about" 2 times faster for MAK, and was expecting better. 2 MOVs are faster than 2 arithmetic ops.(AFAIC)

                Cheers,
                Dale

                Comment


                  #9
                  And my code should have given a ratio less than 1 for the shown TIX
                  Dale

                  Comment

                  Working...
                  X
                  😀
                  🥰
                  🤢
                  😎
                  😡
                  👍
                  👎