hyperfine——准备清除mac上的硬盘缓存?



首先,我是一个初学者,在编程世界中只是一个凡人,所以如果我在此过程中说了一些愚蠢的话,我深表歉意。我需要对3个数据库进行基准测试,所以我使用hyperfine。它工作得很好,除了我意识到我需要在每次运行之前清理硬盘缓存。太好了,Hyperfine有——prepare命令!在文档中,他们给出了linux的一个例子:hyperfine --prepare 'sync; echo 3 | sudo tee /proc/sys/vm/drop_caches' 'grep -R TODO *'我在mac上找了一个,发现了这个:sync && sudo purge我的问题是,如果我运行hyperfine --prepare 'sync && sudo purge',我有这个错误:

error: the following required arguments were not provided:
<command>...
Usage: hyperfine --prepare <CMD> <command>...

有谁知道/命令的正确用法是什么吗?谢谢大家!

tl;博士:我试图找到正确的超细——准备命令来清理我的硬盘缓存

我也有同样的问题…

我认为你需要添加你的基准目标。这是一个缺失的论点。首先给出准备代码来运行,然后提供参数。

hyperfine --prepare 'sync && sudo purge' 'grep -R TODO *'

或者在我的情况下,我想清除缓存并对文件进行基准测试:

hyperfine --prepare 'sync && sudo purge' './day1/target/release/day1'

(全部在一行)

提示错误。


Usage: hyperfine --prepare <CMD> <command>...
error: the following required arguments were not provided:
<command>...
<CMD> is 'sync && sudo purge'
<command> is the file I am targetting './day1/target/release/day1'
you were missing the <command>.

无论如何,这似乎对我有用。我还使用了:

hyperfine -N --prepare 'sync && sudo purge' './day1/target/release/day1'

我添加了一个-N标志,根据超文件注意到shell干扰。不要完全理解命令的顺序。这个也可以试试

我也用过:

hyperfine -N --prepare 'sync && sudo purge' './day1v2/target/release/day1v2' './day1/target/release/day1'

比较两个文件。

见https://github.com/sharkdp/hyperfine

最新更新