mirror of
https://github.com/codex-storage/nim-codex.git
synced 2025-02-07 18:43:50 +00:00
21 lines
376 B
Nim
21 lines
376 B
Nim
## Utilities for serializing profiler metrics.
|
|
|
|
import std/json
|
|
|
|
import asyncprofiler
|
|
|
|
proc `%`*(o: Duration): JsonNode =
|
|
%(o.nanoseconds)
|
|
|
|
proc `%`*(o: cstring): JsonNode =
|
|
%($(o))
|
|
|
|
proc `%`*(o: MetricsSummary): JsonNode =
|
|
var rows = newJArray()
|
|
for (location, metric) in o.pairs:
|
|
var row = %(metric)
|
|
row["location"] = %(location[])
|
|
rows.add(row)
|
|
|
|
rows
|