<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Fri, Jul 22, 2016 at 1:23 PM André Caron &lt;<a href="mailto:andre.l.caron@gmail.com" target="_blank">andre.l.caron@gmail.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Greetings from Canada :-)</div></blockquote><div><br></div><div><span style="line-height:1.5">Hi André, greetings from Brazil. :)</span></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>I&#39;m trying to speed up the CI cycle on one project I&#39;m working on and I&#39;m trying to to figure out where time is spent by the test suite.</div><div><br></div><div>I just discovered the excellent --durations option[1] which prints a neat report containing the slowest tests.</div><div><br></div><div>This has been of much help to get started (I&#39;ve already spotted a few tests to optimize), but it doesn&#39;t seem to track time spent in test fixtures.  I&#39;d like to track metrics for test fixtures, including number of calls, total time spent in order to optimize the slower fixtures.</div></div></blockquote><div><br></div><div>pytest 3.0 (which should be released soon) introduces two new hooks:</div><div><br></div><div>* pytest_fixture_setup(fixturedef, request): executes fixture setup;</div><div>* pytest_fixture_post_finalizer(fixturedef): called after the fixture&#39;s finalizer.</div><div><br></div><div>A plugin could use this to measure fixture setup time:</div><div><br></div><div>@pytest.hookimpl(hookwrapper=True)</div><div>def pytest_fixture_setup(fixturedef, request):</div><div>    started = time.time()</div><div>    yield </div><div>    elapsed = time.time() - started</div><div>    print(&#39;fixture&#39;, <a href="http://fixturedef.name">fixturedef.name</a>, &#39;setup took %.3fs&#39; % elapsed)</div><div><br></div><div>In current pytest I think one would have to resort to printing elapsed time in the fixture functions manually.</div><div><br></div><div>Hope this helps,</div><div>Bruno.</div></div></div>