Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I became curious when I was diffing two large (>326MB) files, and noticed that the second run took much less time than the first. This was frustrating, since I was trying to time the second run, to see how long the diff took. :)

The man page doesn't mention a cache, and searching for 'diff cache' seems to flood me with results for the git diff subcommand, which is not what I'm interested in learning about. So, my question is:

Why did the second run of diff largeFile1 largeFile2 take so much less time than the first? Where can I find more information?

share|improve this question
up vote 2 down vote accepted

diff isn't doing any caching. The OS is. If you are using Linux, you can flush the disk buffers and cache. See How do you empty the buffers and cache on a Linux system?

share|improve this answer
    
Ah, I see. I guess I shouldn't have given up after not finding a 'diff' directory under /var/cache. I'll try to use that link to find more info. 'preciated. – Jon Carter Mar 3 at 17:09

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.