2 ms·
umm this is kinda tongue-in-cheek ``` #include <time.h> #include <stdio.h> int main(int argc, char argv[]) { int i = 0; time_t timep;
by signa11 2y ago
umm this is kinda tongue-in-cheek
```
#include <time.h>
#include <stdio.h>
int main(int argc, char argv[])
{
int i = 0;
time_t timep;
/*
* ok so now we are printing something
**/
printf("Greetings!\n");
/*
* this is a for loop from 0..9
**/
for(i=0; i<10; i++) {
time(&timep);
localtime(&timep);
}
printf("Godspeed, dear friend!\n");
return 0;
}
```
now, the canonical
```
$> gcc tz-test.c -o obj/tz-test
```
now do this
```
$> unset TZ
$> strace -ff ./obj/tz-test 2>&1 | grep 'local' | wc
10 77 851
$> export TZ=:/etc/localtime
$> strace -ff ./obj/tz-test 2>&1 | grep 'local' | wc
1 5 59
```
moral, always set TZ to avoid localtime(3) from stat'ing /etc/localtime :o)
- perfsea 2y agolol never knew about this thanks. Has this actually slowed down someone's code?