Benchmarking inside a module

I’m trying to get benchmark results of a function inside a module displayed in REPL. Here is an example:

module Ex9
using BenchmarkTools

a = rand(100, 100)

function foo(a)
  m = maximum(a)
  map(x -> x<0 ? 0 : x<0.8m ? 1 : x<0.98m ? 2 : 3, a)
end

@benchmark foo($a)
end

Executing this file in VSCode doesn’t show benchmark results. If I change it to:

....
println(@benchmark foo($a))
....

it works a bit better, producing:

Trial(8.732 μs)

but I would prefer the standard @benchmark output. How can I do it?

 show(stdout, MIME("text/plain"), @benchmark foo($a))
2 Likes