title: How to avoid excessive stat(/etc/localtime) calls in strftime() on linux?
body: <p>I left a record processing program of mine running for a few minutes under strace.</p>
  
  <p>This showed in those minutes over 200 000 000 calls to <code>stat("/etc/localtime",..)</code> which sounds a bit excessive and unneeded.</p>
  
  <p>The strace output looks like this:</p>
  
  <pre><code>write(1, "C137015 393393093052629137110 47"..., 16384) = 16384
  stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2225, ...}) = 0
  stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2225, ...}) = 0
  stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2225, ...}) = 0
  stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2225, ...}) = 0
  stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2225, ...}) = 0
  stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2225, ...}) = 0
  stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2225, ...}) = 0
  stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2225, ...}) = 0
  stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2225, ...}) = 0
  stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2225, ...}) = 0
  stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2225, ...}) = 0
  stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2225, ...}) = 0
  stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2225, ...}) = 0
  stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2225, ...}) = 0
  stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2225, ...}) = 0
  stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2225, ...}) = 0
  stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2225, ...}) = 0
  stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2225, ...}) = 0
  stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2225, ...}) = 0
  stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2225, ...}) = 0
  stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2225, ...}) = 0
  stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2225, ...}) = 0
  stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2225, ...}) = 0
  stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2225, ...}) = 0
  stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2225, ...}) = 0
  stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2225, ...}) = 0
  stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2225, ...}) = 0
  read(0, "\224q\1\207\0\0\202\1\4\203\1\4\204\1\1\205\1\1\206\1\7\207\1\6\211\1\22\212\1\22\213\1"..., 16384) = 16384
  </code></pre>
  
  <p>Essentially it turned out to be 1 stat() call for every record processed and the culprit turned out to be this quite ordinary line of code</p>
  
  <pre><code>strftime(call-&gt;date_time,DATELEN,"%Y%m%d %H%M%S",&amp;tm_buf);
  </code></pre>
  
  <p>So - how can I avoid strftime() calling stat(/etc/localtime) at every call?</p>