how to get timestamp in compile-time?

Zólyomi Istvan istvan.zolyomi at
Tue Mar 23 00:35:54 PDT 2010


recently I've been experimenting with metaprogramming in D. I've been trying to create a simple compiler benchmark that can be used like the following oversimplified code:

const time starttime = gettime();
mixin(code); // or any other metaprogramming activity (or even simple code)
const time endtime = gettime();
pragma(msg, "Compiled in ", endtime - starttime);

It works fine with the exception of getting the current time. Unfortunately, I've found no ctfe-capable library function to get the time, and it turned out that special tokens like __TIME__ and its kind are evaluated once during compilation, so it always returns the same time for the same compilation unit.

Do you have any idea how to get the time in compile-time?



More information about the Digitalmars-d-learn mailing list