MacOS的性能诊断

MacOS 的性能诊断

Apple 的开发者网站提供的信息

包含有性能工具,监控工具等一些基本的信息

developer of Apple.com

  1. sc_usuage
  2. fs_usage

方法1

这个是延续下来的方法,就是使用Dtrace,不过现在的MacOS系统对于安全方面进行了增强,系统的完整性检测导致Dtrace无法正常运行。如果只是一个可以运行的二进制文件,看论坛上面的可以将它拷贝到/tmp目录后运行,然后执行Dtrace,就能绕过系统完整性检测,获得结果。

至于如何关闭系统完整性检测,可以到网上搜搜,不过我没有这样的操作。

对于应用程序的性能检查,这个是最好的方式。因为只有这些的指令可以从底层来观察和介入应用程序,从而获得最真实的信息。

方法2

有一本书,叫做《MacOS X internal》,我可能下来会读读,说可以使用这个命令看看vmmap. 可以看到这个命令仅仅是对于进程调用虚拟内存的展现,但是可以作为性能判断的一个要素。

NAME
     vmmap -- Display the virtual memory regions allocated in a process

SYNOPSIS
     vmmap [-w] [-v] [-pages] [-interleaved] [-submap] [-allSplitLibs] [-noCoalesce] [-summary] pid |
           partial-executable-name | memory-graph-file [address]

DESCRIPTION
     vmmap displays the virtual memory regions allocated in a specified process, helping a programmer under-
     stand how memory is being used, and what the purposes of memory at a given address may be.

     vmmap requires one argument -- either the process ID or the full or partial executable name of the
     process to examine, or the pathname of a memory graph file generated by leaks or the Xcode Memory Graph
     Debugger.

     If the optional address is given, information is only shown for the VM region containing that address
     (if any) and the regions around it.

还有就是看看文件的实时读取情况,利用fs_usage.参见下面的说明,它可以获得文件系统的活动状态。也是一个可以参考的要素。

NAME
     fs_usage -- report system calls and page faults related to filesystem activity in real-time

SYNOPSIS
     fs_usage [-e] [-w] [-f mode] [-b] [-t seconds] [-R rawfile [-S start_time] [-E end_time]] [pid | cmd
              [pid | cmd] ...]

DESCRIPTION
     The fs_usage utility presents an ongoing display of system call usage information pertaining to
     filesystem activity.  It requires root privileges due to the kernel tracing facility it uses to oper-
     ate.  By default, the activity monitored includes all system processes except the running fs_usage
     process, Terminal, telnetd, telnet, sshd, rlogind, tcsh, csh, sh, and zsh.  These defaults can be over-
     ridden such that output is limited to include or exclude a list of processes specified by the user.

     The output presented by fs_usage is formatted according to the size of your window.  A narrow window
     will display fewer columns of data.  Use a wide window for maximum data display.  You may override the
     window formatting restrictions by forcing a wide display with the -w option.  In this case, the data
     displayed will wrap when the window is not wide enough.

还有就是最常用的lsof,用于检查打开的文件以及网络连接状态。

​ 比较常用的是 :

				1. lsof -p PID
   					2. lsof /usr/sbin/httpd
   					3. lsof -c httpd  # 包含httpd
   					4. lsof -i udp
   					5. lsof -i tcp
   					6. lsof -i tcp:80
 An  open  file  may be a regular file, a directory, a block special file, a character special file, an executing text reference, a library, a stream or a network
       file (Internet socket, NFS file or UNIX domain socket.)  A specific file or all the files in a file system may be selected by path.

       Instead of a formatted display, lsof will produce output that can be parsed by other programs.  See the -F, option description, and the OUTPUT FOR OTHER PROGRAMS
       section for more information.

       In  addition  to  producing  a  single output list, lsof will run in repeat mode.  In repeat mode it will produce output, delay, then repeat the output operation
       until stopped with an interrupt or quit signal.  See the +|-r [t[m<fmt>]] option description for more information.
| 访问量:
Table of Contents