1 介绍
1.1 Google performance tools
Google performance tools是google公司开发的一套用于C++Profile的工具集。其中包括:
一个优化的内存管理算法—tcmalloc性能优于malloc。HEAPPROFILE=/tmp/netheap ./myprogram
CPUPROFILE=/tmp/profile ./myprogram
1.2 Faad2
Faad2是一个开源的MPEG-4/MPEG-2 AAC 解码库,支持以下特性:
2 安装使用
Goolgle performance tools支持对动态链接库的性能分析,使用之前必须以google CPU Profile的方式编译主程序。这里修改faad的makefile即可:
打开faad2-2.7/frontend中的makefile,添加
LDFLAGS = -L/usr/local/lib (libprofiler的安装路径)
LIBS = -lprofiler
重新编译后即可进行性能分析,终端键入:
CPUPROFILE=perf.out ./faad ***.aac
pprof --text ./faad ./perf.out,输出结果如下:
Using local file ./faad.
Using local file ./perf.out.
Removing _init from all stack traces.
Total: 882 samples
776 88.0% 88.0% 776 88.0% __write
14 1.6% 89.6% 34 3.9% ifilter_bank
13 1.5% 91.0% 13 1.5% to_PCM_16bit (inline)
10 1.1% 92.2% 10 1.1% ComplexMult (inline)
8 0.9% 93.1% 8 0.9% __read
4 0.5% 93.5% 4 0.5% _init
4 0.5% 94.0% 20 2.3% faad_imdct
4 0.5% 94.4% 4 0.5% llseek
4 0.5% 94.9% 4 0.5% lrintf
3 0.3% 95.2% 3 0.3% getaliasbyname_r
3 0.3% 95.6% 10 1.1% passf4pos
3 0.3% 95.9% 5 0.6% quant_to_spec
2 0.2% 96.1% 14 1.6% cfftf1pos (inline)
2 0.2% 96.4% 3 0.3% faad_flushbits (inline)
2 0.2% 96.6% 2 0.2% faad_showbits (inline)
2 0.2% 96.8% 3 0.3% huffman_sign_bits
2 0.2% 97.1% 11 1.2% huffman_spectral_data
2 0.2% 97.3% 2 0.2% iquant (inline)
2 0.2% 97.5% 2 0.2% malloc
2 0.2% 97.7% 18 2.0% spectral_data (inline)
2 0.2% 98.0% 2 0.2% write_audio_16bit (inline)
1 0.1% 98.1% 5 0.6% _IO_file_seekoff
1 0.1% 98.2% 780 88.4% _IO_file_xsputn
1 0.1% 98.3% 9 1.0% _IO_fread
1 0.1% 98.4% 1 0.1% __close
1 0.1% 98.5% 1 0.1% __fxstat64
1 0.1% 98.6% 1 0.1% __mempcpy
1 0.1% 98.8% 1 0.1% __open
1 0.1% 98.9% 1 0.1% decode_scale_factors (inline)
1 0.1% 99.0% 1 0.1% faad_flushbits_ex
1 0.1% 99.1% 1 0.1% faad_get1bit (inline)
1 0.1% 99.2% 3 0.3% huffman_2step_pair
1 0.1% 99.3% 5 0.6% huffman_2step_pair_sign
1 0.1% 99.4% 1 0.1% huffman_binary_pair (inline)
1 0.1% 99.5% 1 0.1% huffman_binary_quad_sign (inline)
1 0.1% 99.7% 1 0.1% huffman_getescape
1 0.1% 99.8% 1 0.1% huffman_sign_bits (inline)
1 0.1% 99.9% 2 0.2% passf2pos
1 0.1% 100.0% 1 0.1% tns_ar_filter (inline)
0 0.0% 100.0% 776 88.0% _IO_do_write
0 0.0% 100.0% 1 0.1% _IO_doallocbuf
0 0.0% 100.0% 1 0.1% _IO_fflush
0 0.0% 100.0% 1 0.1% _IO_fgets
0 0.0% 100.0% 1 0.1% _IO_file_doallocate
0 0.0% 100.0% 1 0.1% _IO_file_fopen
0 0.0% 100.0% 777 88.1% _IO_file_overflow
0 0.0% 100.0% 789 89.5% _IO_file_seek
0 0.0% 100.0% 1 0.1% _IO_file_stat
0 0.0% 100.0% 779 88.3% _IO_fwrite
0 0.0% 100.0% 5 0.6% _IO_puts
0 0.0% 100.0% 8 0.9% _IO_sgetn
0 0.0% 100.0% 882 100.0% __libc_start_main
0 0.0% 100.0% 8 0.9% __underflow
0 0.0% 100.0% 1 0.1% __vfprintf_chk
0 0.0% 100.0% 882 100.0% _start
0 0.0% 100.0% 82 9.3% aac_frame_decode
0 0.0% 100.0% 14 1.6% cfftb
0 0.0% 100.0% 59 6.7% channel_pair_element
0 0.0% 100.0% 1 0.1% close_audio_file
0 0.0% 100.0% 882 100.0% decodeMP4file (inline)
0 0.0% 100.0% 62 7.0% decode_cpe
0 0.0% 100.0% 1 0.1% faad_fprintf
0 0.0% 100.0% 1 0.1% fopencookie
0 0.0% 100.0% 9 1.0% fread (inline)
0 0.0% 100.0% 5 0.6% fseek
0 0.0% 100.0% 3 0.3% huffman_2step_quad
0 0.0% 100.0% 1 0.1% huffman_2step_quad_sign (inline)
0 0.0% 100.0% 4 0.5% huffman_binary_pair_sign (inline)
0 0.0% 100.0% 20 2.3% imdct_long (inline)
0 0.0% 100.0% 19 2.2% individual_channel_stream
0 0.0% 100.0% 882 100.0% main
0 0.0% 100.0% 2 0.2% mp4ff_atom_read
0 0.0% 100.0% 2 0.2% mp4ff_open_read
0 0.0% 100.0% 9 1.0% mp4ff_read_data
0 0.0% 100.0% 2 0.2% mp4ff_read_int32
0 0.0% 100.0% 14 1.6% mp4ff_read_sample
0 0.0% 100.0% 2 0.2% mp4ff_read_stsz (inline)
0 0.0% 100.0% 5 0.6% mp4ff_set_position
0 0.0% 100.0% 5 0.6% mp4ff_set_sample_position
0 0.0% 100.0% 2 0.2% open_audio_file
0 0.0% 100.0% 13 1.5% output_to_PCM
0 0.0% 100.0% 2 0.2% parse_atoms
0 0.0% 100.0% 2 0.2% parse_sub_atoms
0 0.0% 100.0% 62 7.0% raw_data_block
0 0.0% 100.0% 9 1.0% read_callback
0 0.0% 100.0% 40 4.5% reconstruct_channel_pair
0 0.0% 100.0% 1 0.1% scale_factor_data (inline)
0 0.0% 100.0% 1 0.1% side_info (inline)
0 0.0% 100.0% 1 0.1% tns_decode_frame
0 0.0% 100.0% 1 0.1% vfprintf
0 0.0% 100.0% 1 0.1% vfprintf (inline)
0 0.0% 100.0% 778 88.2% write_audio_32bit (inline)
0 0.0% 100.0% 780 88.4% write_audio_file
0 0.0% 100.0% 1 0.1% write_wav_header
分析输出
每一行有6列输出,分别有如下含义: