erlang - 如何检查 Phoenix/Elixir/Erlang 应用程序的正常运行时间?

标签 erlang elixir phoenix-framework

如何检查 Phoenix/Elixir/Erlang 应用程序的正常运行时间?如果您执行 :observer.start() 并查看“系统”选项卡,您可以在“统计”区域中看到正常运行时间。但我希望能够以编程方式提取该信息并将其包含在报告中。我已经弄清楚从哪里获取大部分数据,但我不知道它从哪里获取正常运行时间。

最佳答案

您可以使用统计(运行时):

Returns information about runtime, in milliseconds.

This is the sum of the runtime for all threads in the Erlang runtime system and can therefore be greater than the wall clock time.

统计信息(wall_clock):

Returns information about wall clock. wall_clock can be used in the same manner as runtime, except that real time is measured as opposed to runtime or CPU time.

在这两种情况下,您都需要在程序开始时调用它们以重置它们的计时器。当您想打印耗时时,只需执行以下操作:

{_, Time1} = statistics(runtime).

或者

 {_, Time2} = statistics(wall_clock).

相应地,您将看到 Time1Time2 中的时间。欲了解更多信息,请查看erlang:statistics/1

注意:如果您想要自 Erlang VM 启动以来经过的总时间,您可以从元组中获取第一个元素:{Total_Time, Time_Since_Last_Call} = stats(wall_clock)。

关于erlang - 如何检查 Phoenix/Elixir/Erlang 应用程序的正常运行时间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37116836/

相关文章:

node.js - 使用phoenix_api_docs

使用 ECTO 和 put_assoc/4 进行多对多

postgresql - 如何在 Phoenix 的 Ecto 模型中获取 PostgreSQL 哈希值?

erlang - 在 Windows 下更改 Erlang shell 中的工作目录

string - Erlang替换字符串中的子字符串

erlang - Erlang 头文件中同一函数的多个规范

erlang - 如何将 Erlang 对象结构转换为 Elixir Map?

hex - 如何使用 Elixir 打包/解包十六进制字符串(先是高半字节)

erlang - 我可以修改由带有外部函数的 gen_server 管理的 map 吗?

Elixir 进程限制?