# metronome **Repository Path**: tercero/metronome ## Basic Information - **Project Name**: metronome - **Description**: 用 erlang 实现的节拍器,进程注册后,定时收到节拍消息 - **Primary Language**: Erlang - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2022-02-23 - **Last Updated**: 2022-07-27 ## Categories & Tags **Categories**: Uncategorized **Tags**: make ## README # metronome #### 介绍 用 erlang 实现的节拍器,监听进程加入后,会定时收到节拍消息。 1. 消息体 `{metronome, Count}`,Count 为 1 - 99999999 的循环计数。 2. 监听进程存活,无需节拍时调用 `metronome:quit/1`。 3. 关闭监听进程,不要调用 `metronome:quit/1`,且不调用更高效。 4. 时间回调控制与 timer 模块类似,使用 gen_server 的 timeout 实现。 #### 测试 定时 300 毫秒回调,一次性加入 1000 个监听,5 秒后开始随机关闭监听进程,2 秒内关完。 测试结果如下: 1. 大部分回调稳定在 312 和 313 毫秒。 2. 监听注册、注销和分发压力不大,主要延时发生在节拍控制进程和进程间通信。 3. 测试有误差,详细请 `make test`。 #### 建议 1. 在精确度不高的情况下,且需要单一回调时间情况下使用。 2. 更精确的需求,建议使用 `erlang:send_after/2`。