系统: Linux (Linux ubuntu 4.4.0 x86 _ 64 i7-6700K 4.00 GHz)
消息: 128字节
消息计数: 1000000
管道基准:
Message size: 128
Message count: 1000000
Total duration: 27367.454 ms
Average duration: 27.319 us
Minimum duration: 5.888 us
Maximum duration: 15763.712 us
Standard deviation: 26.664 us
Message rate: 36539 msg/s
FIFO (命名管道)基准:
Message size: 128
Message count: 1000000
Total duration: 38100.093 ms
Average duration: 38.025 us
Minimum duration: 6.656 us
Maximum duration: 27415.040 us
Standard deviation: 91.614 us
Message rate: 26246 msg/s
消息队列基准:
Message size: 128
Message count: 1000000
Total duration: 14723.159 ms
Average duration: 14.675 us
Minimum duration: 3.840 us
Maximum duration: 17437.184 us
Standard deviation: 53.615 us
Message rate: 67920 msg/s
共享内存基准:
Message size: 128
Message count: 1000000
Total duration: 261.650 ms
Average duration: 0.238 us
Minimum duration: 0.000 us
Maximum duration: 10092.032 us
Standard deviation: 22.095 us
Message rate: 3821893 msg/s
TCP 套接字基准:
Message size: 128
Message count: 1000000
Total duration: 44477.257 ms
Average duration: 44.391 us
Minimum duration: 11.520 us
Maximum duration: 15863.296 us
Standard deviation: 44.905 us
Message rate: 22483 msg/s
Unix 域套接字基准测试:
Message size: 128
Message count: 1000000
Total duration: 24579.846 ms
Average duration: 24.531 us
Minimum duration: 2.560 us
Maximum duration: 15932.928 us
Standard deviation: 37.854 us
Message rate: 40683 msg/s
ZeroMQ 基准:
Message size: 128
Message count: 1000000
Total duration: 64872.327 ms
Average duration: 64.808 us
Minimum duration: 23.552 us
Maximum duration: 16443.392 us
Standard deviation: 133.483 us
Message rate: 15414 msg/s
我知道这是一个超级老的线程,但它是一个重要的,所以我想加上我的0.02美元。UDS 在本地 IPC 的概念上要快得多。它们不仅速度更快,而且如果你的内存控制器支持 DMA,那么 UDS 几乎不会给你的 CPU 带来任何负载。DMA 控制器只是卸载 CPU 的内存操作。TCP 需要被打包成大小为 MTU 的块,如果你没有智能网卡或 TCP 卸载在某个特定的硬件,导致相当多的 CPU 负载。根据我的经验,在现代系统中,UDS 在延迟和吞吐量方面都要快5倍左右。