加编译选项 -pg 运行后可以生成函数运行时间的统计,不过就是执行文件有点,跑起来会慢多少没测试过。前一段看汇编说过这个,但一转眼就忘了,记录在此。在 《汇编语言程序设计》这本书里。 生成的文件用来查看 gprof ./test ./gmon.out gprof OPTIONS EXECUTABLE-FILE gmon.out BB-DATA [YET-MORE-PROFILE-DATA-FILES...] [> OUTFILE] gprof产生的信息 % the percentage of the total running time of the time program used by this function. 函数使用时间占所有时间的百分比。 cumulative a running sum of the number of seconds accounted seconds for by this function and those listed above it. 函数和上列函数累计执行的时间。 self the number of seconds accounted for by this seconds function alone. This is the major sort for this listing. 函数本身所执行的时间。 calls the number of times this function was invoked, if this function is profiled, else blank. 函数被调用的次数 self the average number of milliseconds spent in this ms/call function per call, if this function is profiled, else blank. 每一次调用花费在函数的时间microseconds。 total the average number of milliseconds spent in this ms/call function and its descendents per call, if this function is profiled, else blank. 每一次调用,花费在函数及其衍生函数的平均时间microseconds。 name the name of the function. This is the minor sort for this listing. The index shows the location of the function in the gprof listing. If the index is in parenthesis it shows where it would appear in the gprof listing if it were to be printed. |