Thread overview | |||||
---|---|---|---|---|---|
|
March 23, 2010 how to get timestamp in compile-time? | ||||
---|---|---|---|---|
| ||||
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 |
March 23, 2010 Re: how to get timestamp in compile-time? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Zólyomi Istvan | 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 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 |
March 23, 2010 Re: how to get timestamp in compile-time? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Simen kjaeraas | 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 >> > 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. > Or grab an existing one (*nix has 'time' for that). -- ... <IXOYE>< |
Copyright © 1999-2021 by the D Language Foundation