Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uniform decimal digits for test runs summary / PrettyTables.pretty_table #4104

Closed
fingolfin opened this issue Sep 17, 2024 · 0 comments · Fixed by #4106
Closed

Uniform decimal digits for test runs summary / PrettyTables.pretty_table #4104

fingolfin opened this issue Sep 17, 2024 · 0 comments · Fixed by #4106
Labels

Comments

@fingolfin
Copy link
Member

At the end of our test suite, we print a table with the slowest test files, which is quite useful.

┌────────────────────────────────────────────────────────┬──────────────┬───────────────┬─────────────────┬───────────────────┐
│                                               Filename │ Runtime in s │ + Compilation │ + Recompilation │ Allocations in MB │
├────────────────────────────────────────────────────────┼──────────────┼───────────────┼─────────────────┼───────────────────┤
│                        test/Modules/UngradedModules.jl │      1372.22 │       20.0326 │             0.0 │           3340.99 │
│     test/AlgebraicGeometry/Schemes/elliptic_surface.jl │      445.162 │       165.269 │             0.0 │         1.25646e5 │
│    experimental/FTheoryTools/test/literature_models.jl │      223.246 │        4.6469 │             0.0 │           82457.4 │
│          experimental/FTheoryTools/test/tate_models.jl │      129.353 │       16.4472 │             0.0 │           69563.8 │
│              test/PolyhedralGeometry/linear_program.jl │      72.8957 │       0.98791 │             0.0 │           95.7083 │
│                  test/PolyhedralGeometry/polyhedron.jl │       64.557 │        17.781 │             0.0 │           13058.2 │
│        test/AlgebraicGeometry/Schemes/CoveredScheme.jl │       60.829 │       11.9376 │        0.415924 │           8449.28 │
│              test/AlgebraicGeometry/Schemes/Tjurina.jl │      60.8095 │       11.6399 │             0.0 │           16785.6 │
│   test/AlgebraicGeometry/Schemes/DerivedPushforward.jl │      55.5698 │       24.6313 │             0.0 │           17213.6 │
│ experimental/LieAlgebras/test/LieAlgebraModule-test.jl │      50.2391 │       14.9335 │             0.0 │           30064.8 │
└────────────────────────────────────────────────────────┴──────────────┴───────────────┴─────────────────┴───────────────────┘

But I think it would be even better if we used a fixed number of decimal digits after the period (1 or 2), and no scientific format.

That makes it easier to take in how the entries related in size at a glance. Like this (I didn't bother rounding correctly):

┌────────────────────────────────────────────────────────┬──────────────┬───────────────┬─────────────────┬───────────────────┐
│                                               Filename │ Runtime in s │ + Compilation │ + Recompilation │ Allocations in MB │
├────────────────────────────────────────────────────────┼──────────────┼───────────────┼─────────────────┼───────────────────┤
│                        test/Modules/UngradedModules.jl │      1372.22 │         20.03 │             0.0 │            3340.9 │
│     test/AlgebraicGeometry/Schemes/elliptic_surface.jl │       445.16 │        165.26 │             0.0 │          125646.0 │
│    experimental/FTheoryTools/test/literature_models.jl │       223.24 │          4.64 │             0.0 │           82457.4 │
│          experimental/FTheoryTools/test/tate_models.jl │       129.35 │         16.44 │             0.0 │           69563.8 │
│              test/PolyhedralGeometry/linear_program.jl │        72.89 │          0.98 │             0.0 │              95.7 │
│                  test/PolyhedralGeometry/polyhedron.jl │        64.55 │         17.78 │             0.0 │           13058.2 │
│        test/AlgebraicGeometry/Schemes/CoveredScheme.jl │        60.82 │         11.93 │             0.4 │            8449.2 │
│              test/AlgebraicGeometry/Schemes/Tjurina.jl │        60.80 │         11.63 │             0.0 │           16785.6 │
│   test/AlgebraicGeometry/Schemes/DerivedPushforward.jl │        55.56 │         24.63 │             0.0 │           17213.6 │
│ experimental/LieAlgebras/test/LieAlgebraModule-test.jl │        50.23 │         14.93 │             0.0 │           30064.8 │
└────────────────────────────────────────────────────────┴──────────────┴───────────────┴─────────────────┴───────────────────┘

The relevant code for this in test/runtest.jl:

function print_stats(io::IO, stats_dict::Dict; fmt=PrettyTables.tf_unicode, max=50)
  sorted = sort(collect(stats_dict), by=x->x[2].time, rev=true)
  println(io, "### Stats per file")
  println(io)
  table = hcat(first.(sorted), permutedims(reduce(hcat, collect.(values.(last.(sorted))))))
  formatters = nothing
  if haskey(first(values(stats_dict)), :ctime)
    header=[:Filename, Symbol("Runtime in s"), Symbol("+ Compilation"), Symbol("+ Recompilation"), Symbol("Allocations in MB")]
    #formatters = PrettyTables.ft_printf("%.2f%%", [3,4])
  else
    header=[:Filename, Symbol("Time in s"), Symbol("Allocations in MB")]
  end
  PrettyTables.pretty_table(io, table; tf=fmt, max_num_of_rows=max, header=header, formatters=formatters)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants