mirror of
https://github.com/logos-storage/nim-poseidon2.git
synced 2026-02-17 04:03:17 +00:00
24 lines
639 B
Nim
24 lines
639 B
Nim
|
|
import strformat
|
|
import times, strutils
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
func seconds*(x: float): string = fmt"{x:.4f} seconds"
|
|
|
|
func quoted*(s: string): string = fmt"`{s:s}`"
|
|
|
|
template withMeasureTime*(doPrint: bool, text: string, code: untyped) =
|
|
block:
|
|
if doPrint:
|
|
let t0 = epochTime()
|
|
code
|
|
let elapsed = epochTime() - t0
|
|
let elapsedStr = elapsed.formatFloat(format = ffDecimal, precision = 4)
|
|
echo ( text & " took " & elapsedStr & " seconds" )
|
|
else:
|
|
code
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|