gpt4 book ai didi

elisp - 有没有一种简单的方法来计时 elisp 中的函数调用?

转载 作者:行者123 更新时间:2023-12-04 11:38:38 26 4
gpt4 key购买 nike

是的,我知道 emacs 分析器功能。我正在寻找类似于 time 的东西bash 中的关键字,例如:

(time (myfunc)) 

这将返回或打印 myfunc 所花费的时间称呼。有这样的事情吗?

最佳答案

benchmark.el提供 benchmark-runbenchmark-run-compiled功能以及 benchmark版本以交互方式运行。链接的例子:

C-u 512 M-x benchmark (sort (number-sequence 1 512) '<)Elapsed time: 0.260000s (0.046000s in 6 GCs)

The timer used by all those functions is the benchmark-elapse macro, which you can also use directly if desired:

ELISP> (require 'benchmark)
ELISP> (benchmark-elapse
(sit-for 2))
2.00707889

关于elisp - 有没有一种简单的方法来计时 elisp 中的函数调用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21246688/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com