我最近发现两个宏之间存在巨大差异:@benchmark和@time在内存分配信息和时间方面.例如:
@benchmark quadgk(x -> x, 0., 1.)
BenchmarkTools.Trial:
memory estimate: 560 bytes
allocs estimate: 17
--------------
minimum time: 575.890 ns (0.00% GC)
median time: 595.049 ns (0.00% GC)
mean time: 787.248 ns (22.15% GC)
maximum time: 41.578 ?s (97.60% GC)
--------------
samples: 10000
evals/sample: 182
@time quadgk(x -> x, 0., 1.)
0.234635 seconds (175.02 k allocations: 9.000 MiB)
(0.5, 0.0)
Run Code Online (Sandbox Code Playgroud)
为什么这两个例子之间有很大的不同?