現在取り組んでいるプロジェクトの単体テスト スイートを作成しました。私の単体テストは非常に速く実行されていました... 200 以上のテストが数秒以内に実行されました。通常、各テストにかかる時間は 10 ミリ秒未満です。Valgrind と Gcov を使用すると、各テストの実行に 1.5 分以上かかる場合があります。非常に遅い単体テストを経験した人はいますか? Valgrind、gcov、または Google Test は、特定の状況でプログラムの実行を大幅に遅くしますか? さらに紛らわしいのは、ユニット テストの一部は問題なく (つまり、非常に速く) 実行される一方で、他のテストは実行に数秒かかることです。また、単体テストを再度実行すると、同じテストでも実行にかかる時間が異なることがよくあります。私は基本的にボトルネックがどこにあるかを把握しようとしています。以下に例を示します。
[ RUN ] BandwidthAlgorithmTest.TerminalsOnly
[ OK ] BandwidthAlgorithmTest.TerminalsOnly (34 ms)
[ RUN ] BandwidthAlgorithmTest.AlohaAndTerminals
[ OK ] BandwidthAlgorithmTest.AlohaAndTerminals (38 ms)
[ RUN ] BandwidthAlgorithmTest.AllocatePeriodic
[ OK ] BandwidthAlgorithmTest.AllocatePeriodic (304 ms)
[ RUN ] BandwidthAlgorithmTest.AllocatePeriodic_Disabled
[ OK ] BandwidthAlgorithmTest.AllocatePeriodic_Disabled (152 ms)
[ RUN ] BandwidthAlgorithmTest.AllocateFair
[ OK ] BandwidthAlgorithmTest.AllocateFair (109 ms)
[ RUN ] BandwidthAlgorithmTest.AllocateFair_Disabled
[ OK ] BandwidthAlgorithmTest.AllocateFair_Disabled (64 ms)
[----------] 12 tests from BandwidthAlgorithmTest (2763 ms total)
[----------] 7 tests from BacklogHelperTest
[ RUN ] BacklogHelperTest.ChangeInrouteState
[ OK ] BacklogHelperTest.ChangeInrouteState (80613 ms)
[ RUN ] BacklogHelperTest.GetInvalidInroute
[ OK ] BacklogHelperTest.GetInvalidInroute (98471 ms)