Jump to content
Sign in to follow this  
dobbelina

What goes faster?

Recommended Posts

dobbelina

What goes faster/requires less computing ?

Checking for the existence of a file, and then delete it.

or simply do a FileDelete without checking it's presence...

Share this post


Link to post
Share on other sites
czardas

FileDelete without checking will be faster, though you may wish to check that no errors have occured, during deletion.

Edited by czardas

Share this post


Link to post
Share on other sites
GEOSoft

Checking for FileDelete can also be done without checking FileExists()

If FileDelete("c:\some\file.ext") Then
    ;; Do something
Else
    ;; Do something else because the file was not deleted or did not exist.
EndIf

Edit: I should also make you aware of this.

Unless you are checking at least hundreds of files with FileExists() OR you are running an old 286 system with about 4Mb of RAM on Win 3.1, then the time saving will not be noticable. For example, the time it takes to check the existence of 30 files will be less than the time it takes for a blink of the eye. You're talking micro-seconds here.

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites
dobbelina

Ok, thanks for the replys.

At the moment i'm trying to optimize my code, after getting it to work

the way i want.

I realized that some stuff could be put into functions, that gets accessed with

Call, only when needed.

Other stuff wasn't needed (shuffling the code around), so i stripped that away.

Any tips on optimizing is always nice.

Share this post


Link to post
Share on other sites
GEOSoft

Avoiding call is a good start.

Why on earth would you want to use Call("myfunc", $sParam), when you can just use MyFunc($sParam)?

There are times when Call can be handy but normalally it's better to access a function by the second method.


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites
dobbelina

Thanks !

I'm learning here.

As you can see, i still haven't got rid of the "goto" bug from bat scripting :idea:

Share this post


Link to post
Share on other sites
Shafayat

Another useful tip when dealing with files of importance. Especially when debugging.

if @compiled then
filedelete(myfilehere)
else
filerecycle(myfilehere)
endif
this can help you not to loose important files or having to copy or create them again. Edited by Shafayat

[Not using this account any more. Using "iShafayet" instead]

Share this post


Link to post
Share on other sites
GEOSoft

Thanks !

I'm learning here.

As you can see, i still haven't got rid of the "goto" bug from bat scripting :idea:

GoTo and GoSub rode out on the back of a dinosaur and Call should have gone with them.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
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
Sign in to follow this  

×