我创建了一个简单的程序:
#include <unistd.h>
void ssleep(unsigned int s)
{
usleep(1000000*s);
}
int main(int, char**)
{
ssleep(1);
}
在这些命令之后:
sch@sch-K52F:~/test$ g++ -pedantic -Wall main.cpp -pg
sch@sch-K52F:~/test$ ./a.out
sch@sch-K52F:~/test$ gprof -b a.out > profile
我得到一个没有时间摘要的个人资料:
% cumulative self self total
time seconds seconds calls Ts/call Ts/call name
0.00 0.00 0.00 1 0.00 0.00 ssleep(unsigned int)
任何其他代码的情况相同。我错过了什么吗?
我的系统:
sch@sch-K52F:~/test$ uname -a
Linux sch-K52F 3.2.0-45-generic-pae #70-Ubuntu SMP Wed May 29 20:31:05 UTC 2013 i686 i686 i386 GNU/Linux
sch@sch-K52F:~/test$ gprof -v
GNU gprof (GNU Binutils for Ubuntu) 2.22
Based on BSD gprof, copyright 1983 Regents of the University of California.
This program is free software. This program has absolutely no warranty.
谢谢你
编辑 1)
另一个例子:
time seconds seconds calls Ts/call Ts/call name
0.00 0.00 0.00 1482 0.00 0.00 std::_Iter_base<unsigned char*, false>::_S_base(unsigned char*)
0.00 0.00 0.00 1482 0.00 0.00 std::_Niter_base<unsigned char*>::iterator_type std::__niter_base<unsigned char*>(unsigned char*)
0.00 0.00 0.00 1247 0.00 0.00 std::_Vector_base<unsigned char, std::allocator<unsigned char> >::_M_get_Tp_allocator()
0.00 0.00 0.00 988 0.00 0.00 __gnu_cxx::__normal_iterator<unsigned char*, std::vector<unsigned char, std::allocator<unsigned char> > >::base() const
0.00 0.00 0.00 988 0.00 0.00 std::move_iterator<unsigned char*>::base() const
0.00 0.00 0.00 988 0.00 0.00 std::vector<unsigned char, std::allocator<unsigned char> >::size() const
0.00 0.00 0.00 988 0.00 0.00 std::_Iter_base<std::move_iterator<unsigned char*>, true>::_S_base(std::move_iterator<unsigned char*>)
0.00 0.00 0.00 988 0.00 0.00 std::move_iterator<unsigned char*>::move_iterator(unsigned char*)
0.00 0.00 0.00 988 0.00 0.00 std::_Miter_base<std::move_iterator<unsigned char*> >::iterator_type std::__miter_base<std::move_iterator<unsigned char*> >(std::move_iterator<unsigned char*>)
0.00 0.00 0.00 988 0.00 0.00 std::move_iterator<unsigned char*> std::make_move_iterator<unsigned char*>(unsigned char* const&)
0.00 0.00 0.00 741 0.00 0.00 __gnu_cxx::new_allocator<unsigned char>::max_size() const
0.00 0.00 0.00 555 0.00 0.00 operator new(unsigned int, void*)
0.00 0.00 0.00 541 0.00 0.00 void std::_Destroy_aux<true>::__destroy<unsigned char*>(unsigned char*, unsigned char*)
0.00 0.00 0.00 541 0.00 0.00 std::_Vector_base<unsigned char, std::allocator<unsigned char> >::_M_deallocate(unsigned char*, unsigned int)
0.00 0.00 0.00 541 0.00 0.00 void std::_Destroy<unsigned char*>(unsigned char*, unsigned char*)
对于任何代码、任何功能,我总是得到零时间;/