Timer with millisecond precision. The bottom layer is implemented based on epoll_wait and setitimer. The data structure uses a minimum heap, which can support adding a large number of timers.
## Use in the synchronization process to implement Setitimer and signals, such as Manager and TaskWorker processes (Recommended Learning: ## SWOOLE Video Tutorial ) ##Use epoll_wait/kevent/poll/select timeout in an asynchronous process to implement
Performance
The bottom layer uses the minimum heap data structure to implement the timer, The addition and deletion of timers are all memory operations, so the performance is very high.
In the official benchmark script https://github.com/swoole/swoole-src/blob/master/benchmark/timer.php, the time taken to add or delete a timer of 100,000 random times is About 0.08s.~/workspace/swoole/benchmark$ php timer.php add 100000 timer :0.091133117675781s del 100000 timer :0.084658145904541sThe timer is a memory operation and has no IO consumption
Difference
Timer is different from PHP's own pcntl_alarm. pcntl_alarm is implemented based on the clock signal tick function and has some flaws:
It only supports up to seconds, while Timer can reach millisecond level It does not support setting multiple timer programs at the same time pcntl_alarm relies on declare(ticks = 1), and the performance is very poorThe above is the detailed content of Is the swoole timer a single process?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Zend Studio 13.0.1
Powerful PHP integrated development environment

SublimeText3 Mac version
God-level code editing software (SublimeText3)

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool