【发布时间】:2010-07-05 14:50:51
【问题描述】:
我尝试使用 gprof 分析我的 C++ 程序。程序本身运行了大约 53 秒,所以我不明白为什么它说,main 只运行了大约 8.29 秒。对此有何解释?
摘录如下:
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]
【问题讨论】:
-
它是测量挂钟时间还是实际累积的进程使用的 CPU 时间?
-
您是否尝试过通过 unix
time命令运行您的代码?这将向您显示挂钟时间与用户空间时间(您的代码)与内核时间。您希望您的代码受 IO 限制还是 CPU 限制? -
@Rup:“MPQS”几乎可以肯定代表“多重多项式二次筛”,一种用于分解大数的算法。我希望它会大量受 CPU 限制。
-
@Jerry Coffin:确实,MPQS 是多重多项式二次筛 :-)