Description
Original bug ID: 6577
Reporter: @alainfrisch
Assigned to: @alainfrisch
Status: closed (set by @xavierleroy on 2016-12-07T10:34:53Z)
Resolution: fixed
Priority: low
Severity: tweak
Target version: 4.03.0+dev / +beta1
Fixed in version: 4.03.0+dev / +beta1
Category: standard library
Bug description
My intuition was that with the new compile-time based implementation of format strings the following two lines would run at approximately the same speed:
ignore (Printf.sprintf "%Ld" x);
ignore (Printf.sprintf "%s" (Int64.to_string x));
However, some micro-benchmark indicates that the first one is about 33% slower than the second one. Same kind of observation for %ld, but not for %d.
This is not a big deal, but maybe some simple shortcuts for common boxed integer format specifiers could bring some non-negligible speedup.
I assume the performance hit comes from CamlinternalFormat.format_of_aconv. I'd try to specialize it to the three use cases (l, L, n) and always returns string literals, as format_of_iconv.