jai-like CTFE string formating
Sönke Ludwig via Digitalmars-d
digitalmars-d at puremagic.com
Sun Aug 13 12:28:42 PDT 2017
Am 13.08.2017 um 20:25 schrieb Stefan Koch:
> On Sunday, 13 August 2017 at 18:20:15 UTC, Sönke Ludwig wrote:
>> I was a bit shocked by this number and performed a little test with
>> multiple calls to format. Fortunately only the first one takes that
>> long to compile. For 500 different calls I got about 2ms per call on
>> Windows (which might get slowed down somewhat by the slow terminal
>> output):
>>
>> import std.format;
>> template T(size_t i) {
>> static if (i > 0) {
>> pragma(msg, format("Bye %s %s %s %s %s %s %s %s %s %s",
>> i, " I ", "just", " have", " to", " concat", " a lot",
>> " of", " strings ...", 9));
>> enum T = T!(i-1);
>> } else enum T = 0;
>> }
>> enum test = T!500;
>
> Wouldn't you say that 2ms is still a pretty long time for a function call ?
>
For this particular function call, yes, but still a lot less scary ;) To
get some better numbers, can you do a side by side comparison of your
two versions both executed a few hundred times? If the simplified
version still turns out considerably faster then there may be some low
hanging fruits in vibe.d's web/REST modules.
More information about the Digitalmars-d
mailing list