While connected to the web, the following program, which converts a given std::chrono::system_clock::time_point to a string, takes a whopping 1s32ms to complete. However, if my machine is not connected to the web, the program requires a reasonable 54ms.
#include "date/tz.h" // Howard Hinnant's date library
#include <chrono>
#include <iostream>
std::string tp2str(const std::chrono::system_clock::time_point &tp,
const std::string &tz) {
auto z = date::make_zoned(tz, tp);
return date::format("%Y-%m-%d %H:%M:%S %Z (%A)", z);
}
int main() {
const auto now = std::chrono::system_clock::now();
std::cout << tp2str(now, "US/Eastern") << std::endl;
}
Examining the profiler output while connected reveals that the delay is on account of the function sequence date::remote_version ... Curl_http_connect which presumably attempts to connect to a remote web host.
Is there a way to prevent this behaviour while calling date::make_zoned() while still being connected to the web?