Jump to content

Text file delete function


Champak
 Share

Recommended Posts

Hi,

Pity;

I get 15-37x as fast [Compiled 12-28], depending whethether its at the begining, middle, or end;

1376.96Kb
1.34469Mb
so its in the middle;=================================================
_DeleteToLineFoundVBS Time= 208.17
_DeleteTxtInfo Time=        4162.35
so its in the start;=================================================
_DeleteToLineFoundVBS Time= 141.79
_DeleteTxtInfo Time=        5285.05
so its in the end;=================================================
_DeleteToLineFoundVBS Time= 202.83
_DeleteTxtInfo Time=        3076.89
finished         ;=================================================

Best, Randall

[** PS I don't know the regExp to use for AutoIt here, so have only used the vbs equivalent I know works;; can someone look at the commented code for the AutoIt expression and give me the equivalent to test that too please?....?]

Edited by randallc
Link to comment
Share on other sites

  • Moderators

How does this one compare randallc

Func _DeleteTxtInfoEx($hFile, $sText)
    Local $hRead = FileRead($hFile)
    FileClose(FileOpen($hFile, 2))
    Return FileWrite($hFile, StringTrimLeft($hRead, _
        StringInStr($hRead, $sText, 1) + (StringLen($sText) + 1)))
EndFunc
Seemed to be 20 + x's faster than my other one itself.

Edit:

This is what I got with your test

1376.96Kb

1.34469Mb

so its in the middle;=================================================

_DeleteToLineFoundVBS Time= 371.31

_DeleteTxtInfo Time= 63.78

so its in the start;=================================================

_DeleteToLineFoundVBS Time= 195.99

_DeleteTxtInfo Time= 79.12

so its in the end;=================================================

_DeleteToLineFoundVBS Time= 189.18

_DeleteTxtInfo Time= 152.44

finished ;=================================================

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

@SmOke_N!

Fantastic,

The only extra mileage I can think of is IF you are prepared to say it is in the last 10%, 0.5%, or whatever, so you accept trusting it is in a part of the tail, and use your code on the fragment read;

Func _DeleteToLineFound_APIread($ReadFile, $IDLine, $WriteFile, $i_Skip = 0)
    $i_Pos= ($i_Skip / 100) * FileGetSize($ReadFile)
    $h_File = _APIFileOpen ($ReadFile)
    _APIFileSetPos ($h_File, Int($i_Pos))
    $s_ReadID = _APIFileRead ($h_File, FileGetSize($ReadFile) - Int($i_Pos))
    _APIFileClose ($h_File)
    FileWrite($WriteFile, StringTrimLeft($s_ReadID, _
            StringInStr($s_ReadID, $IDLine, 1) + (StringLen($IDLine) + 1)))
EndFunc   ;==>_DeleteToLineFound_APIread
Then;

1376.96Kb

1.34469Mb

so its in the middle;=================================================

_DeleteToLineFound_APIread Time30= 70.54

_DeleteTxtInfoEx Time= 72.8

so its in the start;=================================================

_DeleteToLineFound_APIread Time0= 102.27

_DeleteTxtInfoEx Time= 65.37

so its in the end 0.5%;=================================================

_DeleteToLineFound_APIread Time99.5= 4.5

_DeleteTxtInfoEx Time= 79.73

so its in the end 10%;=================================================

_DeleteToLineFound_APIread Time90= 13.76

_DeleteTxtInfoEx Time= 79.76

finished ;=================================================

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...