本帖最后由 afan 于 2012-1-12 23:04 编辑
回复 afan
是你说过再小也能看出来的,小文件也确实能看出效率差别,要不你上传个 ...
binghc 发表于 2012-1-12 22:34
你那个代码有误,@extended 所处的位置已经没有意义了~ 而且我又不用 SCITE 的,ConsoleWrite 害人。。。$sF = RegRead('HKLM\SOFTWARE\AutoIt v3\AutoIt', 'InstallDir') & '\Include\StructureConstants.au3'
$sOut = ''
$ts = TimerInit()
$iL = _FileLineFindKey($sF, 'ToolTip Structures')
$sOut &= 'StringRegExpReplace: ' & @TAB & TimerDiff($ts) & @TAB & $iL & @LF
$ts = TimerInit()
$iL = _FileLineFindKey1($sF, 'ToolTip Structures')
$sOut &= 'StringReplace: ' & @TAB & @TAB & TimerDiff($ts) & @TAB & $iL
MsgBox(0, '结果', $sOut)
Func _FileLineFindKey($sFileName, $sKey)
Local $str = FileRead($sFileName)
Local $iStart = StringInStr($str, $sKey)
If @error Then Return SetError(1)
Local $str1 = StringMid($str, 1, $iStart)
StringRegExpReplace($str1, @CRLF, '')
Return @extended + 1
EndFunc ;==>_FileLineFindKey
Func _FileLineFindKey1($sFileName, $sKey)
Local $str = FileRead($sFileName)
Local $iStart = StringInStr($str, $sKey)
If @error Then Return SetError(1)
Local $str1 = StringMid($str, 1, $iStart)
StringReplace($str1, @CRLF, '')
Return @extended + 1
EndFunc ;==>_FileLineFindKey
|