mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Add profile info to JSON output
This commit is contained in:
parent
df6431f2d7
commit
4eb8eadd9e
1 changed files with 23 additions and 1 deletions
|
@ -67,7 +67,29 @@ module Spectator::Formatting
|
||||||
|
|
||||||
# Adds the profile information to the document.
|
# Adds the profile information to the document.
|
||||||
private def profile(profile)
|
private def profile(profile)
|
||||||
raise NotImplementedError.new("profile")
|
@json.field("profile") do
|
||||||
|
@json.object do
|
||||||
|
@json.field("count", profile.size)
|
||||||
|
@json.field("time", profile.total_time.to_s)
|
||||||
|
@json.field("percentage", profile.percentage)
|
||||||
|
@json.field("results") do
|
||||||
|
@json.array do
|
||||||
|
profile.each do |result|
|
||||||
|
profile_entry(result)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Adds a profile entry to the document.
|
||||||
|
private def profile_entry(result)
|
||||||
|
@json.object do
|
||||||
|
@json.field("example", result.example)
|
||||||
|
@json.field("time", result.elapsed.to_s)
|
||||||
|
@json.field("source", result.example.source)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue