为什么syslog比文件IO慢得多?
我编写了一个简单的测试程序来测量syslog函数的性能。这是我的测试系统的结果:(带有Linux 2.6.32-5-amd64的Debian 6.0.2) 测试用例调用有效负载持续时间 [] [MB] [s] [MB / s] -------------------- ---------- ---------- ---------- ---------- 系统日志200000 10.00 7.81 1.28 系统日志%s 200000 10.00 9.94 1.01 写/ dev / null 200000 10.00 0.03 343.93 printf%s 200000 10.00 0.13 76.29 测试程序进行了200000次系统调用,每次调用期间写入50字节数据。 为什么Syslog比文件IO慢十倍? 这是我用来执行测试的程序: #include <fcntl.h> #include <stdio.h> #include <string.h> #include <sys/stat.h> #include <sys/time.h> …