Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ main only uses ~20% time says gprof

Tags:

c++

gprof

I tried profiling my C++ program with gprof. The program itself ran for about 53 seconds, so I dont understand why it says, main only ran for about 8.29 seconds. Any explanation on this?

Here is an excerpt:

index % time    self  children    called     name
                                                 <spontaneous>
[2]     20.5    0.00    8.29                 main [2]
                0.00    8.28       1/1           MPQS::start(std::basic_ofstream<char, std::char_traits<char> >&) [3]
                0.00    0.01       1/1           MPQS::MPQS(NTL::ZZ, long) [36]
                0.00    0.00       1/1           MPQS::~MPQS() [78]
-----------------------------------------------
                0.00    8.28       1/1           main [2]
[3]     20.5    0.00    8.28       1         MPQS::start(std::basic_ofstream<char, std::char_traits<char> >&) [3]
                7.15    1.08     801/801         MPQS::sieve() [4]
                0.00    0.04     801/801         MPQS::find_smooth_vals() [23]
                0.01    0.00       1/1           MPQS::try_solutions(NTL::mat_GF2&) [35]
                0.00    0.00     801/801         MPQS::compute_coeffecients() [59]
-----------------------------------------------
                7.15    1.08     801/801         MPQS::start(std::basic_ofstream<char, std::char_traits<char> >&) [3]
[4]     20.4    7.15    1.08     801         MPQS::sieve() [4]
                1.08    0.00     801/801         MPQS::find_candidates() [9]
like image 525
Martin Lauridsen Avatar asked Nov 05 '22 11:11

Martin Lauridsen


1 Answers

Were you printing results to the console? gprof doesn't count blocked time. See this.

like image 106
Mike Dunlavey Avatar answered Nov 12 '22 09:11

Mike Dunlavey