apt-get install strace (一般LIINUX都带有此命令)
apache2clt -X -t restart
ps aux|grep www-data
strace -p APACHE进程ID
<?php
echo phpinfo();
?>
Process 4575 attached - interrupt to quit
accept4(3, {sa_family=AF_INET, sin_port=htons(43941), sin_addr=inet_addr("127.0.0.1")}, [16], SOCK_CLOEXEC) = 10
semop(229378, {{0, 1, SEM_UNDO}}, 1) = 0
getsockname(10, {sa_family=AF_INET, sin_port=htons(80), sin_addr=inet_addr("127.0.0.1")}, [16]) = 0
fcntl(10, F_GETFL) = 0x2 (flags O_RDWR)
fcntl(10, F_SETFL, O_RDWR|O_NONBLOCK) = 0
read(10, "GET /index.php HTTP/1.1\r\nHost: l"..., 8000) = 322
stat("/var/www/index.php", {st_mode=S_IFREG|0644, st_size=243, ...}) = 0
setitimer(ITIMER_PROF, {it_interval={0, 0}, it_value={60, 0}}, NULL) = 0
rt_sigaction(SIGPROF, {0x7f002962dac0, [PROF], SA_RESTORER|SA_RESTART, 0x7f002c4a64a0}, {0x7f002962dac0, [PROF], SA_RESTORER|SA_RESTART, 0x7f002c4a64a0}, 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [PROF], NULL, 8) = 0
umask(077) = 022
umask(022) = 077
getcwd("/home/linux", 4095) = 12
chdir("/var/www") = 0
setitimer(ITIMER_PROF, {it_interval={0, 0}, it_value={30, 0}}, NULL) = 0
lstat("/var/www/index.php", {st_mode=S_IFREG|0644, st_size=243, ...}) = 0
lstat("/var/www", {st_mode=S_IFDIR|0777, st_size=4096, ...}) = 0
lstat("/var", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
open("/var/www/index.php", O_RDONLY) = 11
fstat(11, {st_mode=S_IFREG|0644, st_size=243, ...}) = 0
fstat(11, {st_mode=S_IFREG|0644, st_size=243, ...}) = 0
fstat(11, {st_mode=S_IFREG|0644, st_size=243, ...}) = 0
fstat(11, {st_mode=S_IFREG|0644, st_size=243, ...}) = 0
mmap(NULL, 243, PROT_READ, MAP_SHARED, 11, 0) = 0x7f002d2ee000
munmap(0x7f002d2ee000, 243) = 0
close(11) = 0
stat("/tmp/cachegrind.out.4575", {st_mode=S_IFREG|0644, st_size=335, ...}) = 0
open("/tmp/cachegrind.out.4575", O_RDWR) = 11
flock(11, LOCK_EX|LOCK_NB) = 0
open("/tmp/cachegrind.out.4575", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 12
dup3(12, 11, 0) = 11
close(12) = 0
flock(11, LOCK_EX|LOCK_NB) = 0
fstat(11, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f002d2ee000
write(11, "version: 1\ncreator: xdebug 2.2.1"..., 96) = 96
write(11, "fl=php:internal\nfn=php::var_dump"..., 33) = 33
write(11, "4 28\n\n", 6) = 6
uname({sys="Linux", node="linuxmint", ...}) = 0
brk(0x7f002f584000) = 0x7f002f584000
brk(0x7f002f5c4000) = 0x7f002f5c4000
brk(0x7f002f604000) = 0x7f002f604000
write(11, "fl=php:internal\nfn=php::phpinfo\n", 32) = 32
write(11, "5 6620\n\n", 8) = 8
write(11, "fl=/var/www/index.php\nfn={main}\n"..., 48) = 48
write(11, "1 509\ncfl=php:internal\ncfn=php::"..., 112) = 112
chdir("/home/linux") = 0
umask(022) = 022
setitimer(ITIMER_PROF, {it_interval={0, 0}, it_value={0, 0}}, NULL) = 0
close(11) = 0
munmap(0x7f002d2ee000, 4096) = 0
setitimer(ITIMER_PROF, {it_interval={0, 0}, it_value={0, 0}}, NULL) = 0
brk(0x7f002f544000) = 0x7f002f544000
writev(10, [{"HTTP/1.1 200 OK\r\nDate: Sun, 20 O"..., 275}, {"\37\213\10\0\0\0\0\0\0\3", 10}, {"\355}{{\342\270\322\347\377\363)\364\346\2353\323}\336p1\20B\222\356\354!@\22\316p;@"..., 8096},
可以看到C函数的调用,对性能对比优化很重要!