使用Google performance tools侦测Faad2性能

1 介绍

1.1 Google performance tools

Google performance tools是google公司开发的一套用于C++Profile的工具集。其中包括:

一个优化的内存管理算法—tcmalloc性能优于malloc。 
一个用于CPU profile的工具,用于检测程序的性能热点,这个功能和gprof类似。
一个用于堆检查工具,用于检测程序在是够有内存泄露,这个功能和valgrind类似。
一个用于Heap profile的工具,用于监控程序在执行过程的内存使用情况。
官方文档:
http://code.google.com/p/google-perftools/wiki/GooglePerformanceTools
 
它的使用方式比较简单:首先在编译程序的时候加上相应的链接库,然后在运行程序时
通过设置相应的环境变量来激活工具。
 
1.使用其提供的内存管理函数---TC Malloc:
       gcc [...] -ltcmalloc  
 
2.使用其堆内存检查工具:
       gcc [...] -o myprogram -ltcmalloc
       HEAPCHECK=normal ./myprogram   
 
3.使用Heap Profiler:
      gcc [...] -o myprogram -ltcmalloc

      HEAPPROFILE=/tmp/netheap ./myprogram  

 
4.使用Cpu Profiler:
      gcc [...] -o myprogram -lprofiler

      CPUPROFILE=/tmp/profile ./myprogram

1.2 Faad2

Faad2是一个开源的MPEG-4/MPEG-2 AAC 解码库,支持以下特性:

  • Portable
  • Reasonably fast
  • LC, Main, LTP, SBR, PS support
  • DRM support through DreaM
  • DAB+ support
官方网址: http://www.audiocoding.com/


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列输出,分别有如下含义:

  1. Number of profiling samples in this function
  2. Percentage of profiling samples in this function
  3. Percentage of profiling samples in the functions printed so far
  4. Number of profiling samples in this function and its callees
  5. Percentage of profiling samples in this function and its callees
  6. Function name




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值