Skip to content

Commit

Permalink
make the md function optionally print to stdout
Browse files Browse the repository at this point in the history
  • Loading branch information
sunxd3 committed Mar 3, 2024
1 parent 32ebc63 commit a8c33b0
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions test/profile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -131,36 +131,40 @@ function print_pure_text_table(result_dict)
end
end

function print_markdown_table_to_file(result_dict, filename)
open(filename, "w") do file
# Define the table header
function print_markdown_table_to_file(result_dict, filename=nothing)
output_target = filename !== nothing ? open(filename, "w") : stdout

try
println(
file,
output_target,
"| Example Name | Category | Median Time | Minimum Time | Maximum Time | Memory Usage |",
)
println(
file,
output_target,
"|--------------|----------|-------------|--------------|--------------|--------------|",
)

# Iterate through each example and its benchmarks to populate the table rows
for (name, benchmarks) in result_dict
first_category = true
for (category, results) in benchmarks
if first_category
println(
file,
output_target,
"| $(name) | $(category) | $(results["median"]) | $(results["minimum"]) | $(results["maximum"]) | $(results["memory"]) |",
)
first_category = false
else
println(
file,
output_target,
"| | $(category) | $(results["median"]) | $(results["minimum"]) | $(results["maximum"]) | $(results["memory"]) |",
)
end
end
end
finally
if filename !== nothing
close(output_target)
end
end
end

Expand Down

0 comments on commit a8c33b0

Please sign in to comment.