-
Notifications
You must be signed in to change notification settings - Fork 597
Description
Working on slog-rs - a logger, I've been doing some benchmarking, and getting a current timestamp (formatted) from chrono is taking a lot of time.
Fist I've discovered that just taking time (without formatting) takes around 60ns in my benchmarks. Does it require doing two syscalls (one for time, one for timezone)? I've filled rust-lang/rust#36358 to inquire why it isn't faster.
Second formatting is taking around 500ns, which seems too much. I wish formatting provided something like fn fmt_rfc3339<W : io::Write>(&self, io : W) -> io::Result<()> which does not require any allocation. Also, when investigating the code, it seems there's a lot of cloned() calls, and the whole thing is based on StrftimeItems which like printf in C: scans the format every time.