digitalmars.D.learn - how to get timestamp in compile-time?
- =?ISO-8859-1?Q?Z=f3lyomi_Istvan?= <istvan.zolyomi gmail.com> Mar 23 2010
- "Simen kjaeraas" <simen.kjaras gmail.com> Mar 23 2010
- BCS <none anon.com> Mar 23 2010
Hi, 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? thanks István
Mar 23 2010
On Tue, 23 Mar 2010 08:35:54 +0100, Z=C3=B3lyomi Istvan = <istvan.zolyomi gmail.com> wrote:Hi, 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 =3D gettime(); mixin(code); // or any other metaprogramming activity (or even simple =
code) const time endtime =3D 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? thanks Istv=C3=A1n
Currently not possible, as far as I know. If you must, try instead to make a tiny program that launches DMD, and times its running time. -- = Simen
Mar 23 2010
Hello Simen,On Tue, 23 Mar 2010 08:35:54 +0100, Zólyomi Istvan <istvan.zolyomi gmail.com> wrote:Hi, 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? thanks István
If you must, try instead to make a tiny program that launches DMD, and times its running time.
Or grab an existing one (*nix has 'time' for that). -- ... <IXOYE><
Mar 23 2010








BCS <none anon.com>