diff --git a/Project.toml b/Project.toml index 02e79a5..bf68e9a 100644 --- a/Project.toml +++ b/Project.toml @@ -2,7 +2,7 @@ name = "GFlops" uuid = "2ea8233c-34d4-5acc-88b4-02f326385bcc" license = "MIT" authors = ["François Févotte "] -version = "0.1.7" +version = "0.1.8" [deps] BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf" @@ -15,8 +15,8 @@ Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" [compat] BenchmarkTools = "^0.4.2, 0.5, 0.6, 0.7, 1" Cassette = "^0.2.3, 0.3.2" -PrettyTables = "^0.12, 1" -julia = "^1" +PrettyTables = "^2" +julia = "^1.6" [extras] Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" diff --git a/src/Counter.jl b/src/Counter.jl index 44e2787..7bdc9f3 100644 --- a/src/Counter.jl +++ b/src/Counter.jl @@ -19,6 +19,10 @@ end import Base: ==, *, show function Base.show(io::IO, c::Counter) + fl = flop(c) + print(io, "Flop Counter: $fl flop") + fl == 0 && return + type_names = [typ for (typ, _) in typs] type_suffix = [suffix for (_, suffix) in typs] op_names = [name for (name, _) in ops] @@ -27,18 +31,15 @@ function Base.show(io::IO, c::Counter) name in op_names, suffix in type_suffix] - fl = flop(c) - print(io, "Flop Counter: $fl flop") - fl == 0 && return + # PrettyTables now needs data to be filtered ahead of time: + rows = filter(i -> any(mat[i,:] .> 0), 1:size(mat, 1)) + cols = filter(i -> any(mat[:,i] .> 0), 1:size(mat, 2)) + mat = mat[rows, cols] print(io, "\n") - fc(data, i) = any(data[:,i] .> 0) - fr(data, i) = any(data[i,:] .> 0) - pretty_table(io, mat, - header = type_names, - row_names = op_names, - filters_col = (fc,), - filters_row = (fr,), + pretty_table(io, mat; + header = type_names[cols], + row_labels = op_names[rows], newline_at_end = false) end diff --git a/test/runtests.jl b/test/runtests.jl index bbd3611..319827d 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -46,6 +46,22 @@ GFlops.times(::BenchmarkTools.Trial) = [2.0, 3.0] @test occursin(" 1 ", str) end end + + @testset "display mixed" begin + let + cnt = GFlops.Counter() + cnt.add32 = 1 + cnt.mul64 = 2 + str = string(cnt) + @test occursin("Float32", str) + @test occursin("Float64", str) + @test occursin("add", str) + @test occursin("mul", str) + @test !occursin("div", str) + @test occursin(" 1 ", str) + @test occursin(" 2 ", str) + end + end end @testset "@count_ops" begin