Swoole的定时器是否属于单进程运行模式?
- 内容介绍
- 文章标签
- 相关推荐
本文共计215个文字,预计阅读时间需要1分钟。
相关专题
在同步进程中使用setitimer和信号实现,如Manager和TaskWorker进程 (推荐学习: swoole视频教程)
在异步进程中使用epoll_wait/kevent/poll/select超时时间实现
性能
底层使用最小堆数据结构实现定时器,定时器的添加和删除,全部为内存操作,因此性能是非常高的。
官方的基准测试脚本 https://github.com/swoole/swoole-src/blob/master/benchmark/timer.php 中,添加或删除10万个随机时间的定时器耗时为0.08s左右。
~/workspace/swoole/benchmark$ php timer.php add 100000 timer :0.091133117675781s del 100000 timer :0.084658145904541s
定时器是内存操作,无IO消耗
差异
Timer与PHP本身的pcntl_alarm是不同的。
本文共计215个文字,预计阅读时间需要1分钟。
相关专题
在同步进程中使用setitimer和信号实现,如Manager和TaskWorker进程 (推荐学习: swoole视频教程)
在异步进程中使用epoll_wait/kevent/poll/select超时时间实现
性能
底层使用最小堆数据结构实现定时器,定时器的添加和删除,全部为内存操作,因此性能是非常高的。
官方的基准测试脚本 https://github.com/swoole/swoole-src/blob/master/benchmark/timer.php 中,添加或删除10万个随机时间的定时器耗时为0.08s左右。
~/workspace/swoole/benchmark$ php timer.php add 100000 timer :0.091133117675781s del 100000 timer :0.084658145904541s
定时器是内存操作,无IO消耗
差异
Timer与PHP本身的pcntl_alarm是不同的。

