Announcement

Collapse
No announcement yet.

Thread Life

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

  • #21
    1. When there are no files the folder is removed with RMDIR (not sure how fast that is?)
    1a. What if there are subfolders? Won't it fail?

    2. If files exist the folder is renamed and deleted using shell
    Why is an empty folder created with MKDIR$

    3. Why not just remove the original folder using shell and eliminate all the renaming?
    4. No error checking.

    5. Shell method does more work removing subfolders?


    Now the testing of DIR:
    Not sure it is a valid test using the same folder due to cache?


    Changed code a bit and used ISFALSE since testing for LEN = 0.
    The string compare = "" is often faster.
    I thought it would be slower.

    Code:
    #DIM ALL
    %times=50000
    #INCLUDE "win32api.inc"
    FUNCTION PBMAIN() AS LONG
     LOCAL i,StartTick1,EndTick1,StartTick2,Endtick2 AS LONG, sfolder AS STRING
    
     sfolder = "c:\pbwin10\*"
    
     StartTick1 = GetTickCount
     FOR i = 1 TO %times
      IF ISFALSE(LEN(DIR$(sfolder))) THEN ITERATE
     NEXT i
     EndTick1 = GetTickCount
    
     StartTick2=GetTickCount
     FOR i = 1 TO %times
      IF DIR$(sFolder) = "" THEN ITERATE
     NEXT i
     EndTick2=GetTickCount
     ? USING$("LEN # vs empty #",EndTick1-StartTick1,EndTick2-StartTick2),%MB_SYSTEMMODAL
    END FUNCTION
    How long is an idea? Write it down.

    Comment


    • #22
      Hey Mike!

      I hope I interpreted the questions correctly. Let me know if I nee to say more.

      >>>1a. What if there are subfolders? Won't it fail?
      No, because the earlier Only %SubDir test detects that condition.


      >>>Why is an empty folder created with MKDIR$
      In my app (gbThreads), I want to clear the 50K files in a folder so I can put new ones in it. The MKDIR is used to create a folder by the same name, but now empty for processing. That is after the original folder is renamed out of the way.


      >>>3. Why not just remove the original folder using shell and eliminate all the renaming?
      Speed. The best CMD can do is a 30s deletion of a folder containing 50K files. I wanted skip that 30s delay. In the gbThreads index builder, we're talking about 1.5 minutes out of 30. So nothing huge, but I hope to add in other changes to get the 30 down even further.


      4. No error checking.
      True. However, the code tests for conditions I think might fail. Were there any particular errors I should also cover?


      5. Shell method does more work removing subfolders?
      In my situation, there are no subfolders. Certainly not subfolders which also contain 50K files. The use of Shell was convenient to remove both the files and the folder with a single command.. Deleting any possible subfolders was a bonus.

      Comment


      • #23
        Makes sense now that I know you reuse folders and have handled possible error.
        How long is an idea? Write it down.

        Comment

        Working...
        X