Mercurial > games > semicongine
changeset 1338:1d77dfecdabe
did: disable side effects for time logging
author | sam <sam@basx.dev> |
---|---|
date | Sat, 24 Aug 2024 17:33:18 +0700 |
parents | 164276e8697f |
children | 6e3359477889 |
files | semicongine/core/utils.nim |
diffstat | 1 files changed, 10 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/semicongine/core/utils.nim Sat Aug 24 14:10:21 2024 +0700 +++ b/semicongine/core/utils.nim Sat Aug 24 17:33:18 2024 +0700 @@ -42,17 +42,21 @@ template TimeAndLog*(body: untyped): untyped = when ENABLE_TIMELOG: - let t0 = getMonoTime() - body - echo (getMonoTime() - t0).inNanoseconds.float / 1_000_000 + {.cast(noSideEffect).}: + let t0 = getMonoTime() + body + {.cast(noSideEffect).}: + debugecho (getMonoTime() - t0).inNanoseconds.float / 1_000_000 else: body template TimeAndLog*(name: string, body: untyped): untyped = when ENABLE_TIMELOG: - let t0 = getMonoTime() - body - echo name, ": ", (getMonoTime() - t0).inNanoseconds.float / 1_000_000, "ms" + {.cast(noSideEffect).}: + let t0 = getMonoTime() + body + {.cast(noSideEffect).}: + debugecho name, ": ", (getMonoTime() - t0).inNanoseconds.float / 1_000_000, "ms" else: body