in reply to Will checking last modified date take more time than just overwriting?

G'day Lady Aleena,

The answer is going to depend on the size of your files and how many of them have changed; however, unless you have masses and masses of data to backup any only a very, very tiny amount hasn't changed, I would be extremely surprised if the time taken by calls to stat was in any way a limiting factor compared to the amount of time taken to move data between drives (C: to J:). So, while I don't have details on your data, either in terms of size or modifications, I would generally expect an incremental backup to take less time than a full backup.

You could speed up your script a bit by removing the get_mod_time() subroutine and rewriting same_mod_time() as:

sub same_mod_time { (stat($_[0]))[9] == (stat($_[1]))[9] }

However, the backup process is I/O bound and I doubt that would really have any noticeable affect.

If you're interested, here's my test for that code:

-- Ken

Replies are listed 'Best First'.
Re^2: Will checking last modified date take more time than just overwriting?
by Lady_Aleena (Priest) on Aug 19, 2013 at 08:32 UTC

    This might be a dumb question, but does your same_mod_time return 0 or 1 without the return?

    Data details:

    • checkbook.xls changes 2 or 3 times a month
    • Outlook.pst changes daily
    • gaming has 21 files in 5 folders, and I haven't touched it for a while
    • fantasy has 2252 files in 520 folders (this folder is huge!)
    • stylers.xml hasn't changed in like forever
    • hexchat has 82 files in 6 folders

    Thanks for stopping by.

    Have a cookie and a very nice day!
    Lady Aleena
      "This might be a dumb question, but does your same_mod_time return 0 or 1 without the return?"

      It returns TRUE or FALSE, i.e. whatever (stat($_[0]))[9] == (stat($_[1]))[9] evaluates to. In string context, that would be "1" or ""; in numeric context, that would be 1 or 0.

      Modifying the test code I posted previously to demonstrate this:

      $ > xxx 2> yyy $ perl -Mstrict -Mwarnings -E ' sub same_mod_time { (stat($_[0]))[9] == (stat($_[1]))[9] } say ">>>" . same_mod_time(qw{xxx yyy}) . "<<<"; ' >>>1<<< $ perl -Mstrict -Mwarnings -E ' sub same_mod_time { (stat($_[0]))[9] == (stat($_[1]))[9] } say 0 + same_mod_time(qw{xxx yyy}); ' 1 $ > xxx $ perl -Mstrict -Mwarnings -E ' sub same_mod_time { (stat($_[0]))[9] == (stat($_[1]))[9] } say ">>>" . same_mod_time(qw{xxx yyy}) . "<<<"; ' >>><<< $ perl -Mstrict -Mwarnings -E ' sub same_mod_time { (stat($_[0]))[9] == (stat($_[1]))[9] } say 0 + same_mod_time(qw{xxx yyy}); ' 0

      The presence or absence of the return keyword, in that subroutine, is immaterial. Here's what the doco says:

      "return EXPR
      ...
      Returns from a subroutine, eval, or do FILE with the value given in EXPR.
      ...
      In the absence of an explicit return, a subroutine, eval, or do FILE automatically returns the value of the last expression evaluated. ..."

      -- Ken