The following code has a runtime of over 60 seconds.
#include <time.h>
#include <stdint.h>
int main() {
time_t tm = INT64_MAX;
localtime(&tm);
}
You might ask "BertalanD, who in their right mind would write code like this?" Apparently a bunch of ports that use autotools (like bash
), as they use this to determine if our mktime
implementation works correctly. They actually have a 60-second timeout, but they actually run this test multiple times with slightly different values...
The reason for this slowness is that we use a linear-time algorithm to determine how many years have passed since the Unix epoch.
serenity/Userland/Libraries/LibC/time.cpp
Lines 96 to 100 in 05cdfb8
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too