bench::mark未返回mean和max运行时长,与帮助文档不符求解答
Hey there! Let me help you figure out why you're not seeing mean and max in your bench::mark() results.
The issue boils down to the version of the bench package you're using (1.0.4) being an older release. Back in this version, the default output of bench::mark() only included metrics like min, median, itr/sec, etc.—mean and max weren't part of the default result columns.
But don't worry, you have two solid ways to get those values:
- Calculate them manually from raw time data: The
timecolumn in your result object holds all individual run times from the benchmark. You can compute mean and max directly from it:# Get mean run time mean(res$time) # Get max run time max(res$time) - Upgrade the
benchpackage: If you update to a newer version (2.0.0 or later),bench::mark()will include mean and max in the default output automatically. You can even customize which metrics show up using thesummaryparameter:# In newer versions, specify exactly which stats you want res <- bench::mark(rnorm(1e5), summary = c("min", "median", "mean", "max")) names(res)
The reason this feels conflicting with the help docs is probably because you're looking at documentation for a newer version of bench—the docs were updated to reflect the expanded default metrics in later releases.
内容的提问来源于stack exchange,提问作者Sebastian
相关产品推荐
相关产品推荐

