Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

debug_data takes a lot of time doing nothing useful #1040

Closed
bukzor opened this issue Dec 19, 2017 · 3 comments
Closed

debug_data takes a lot of time doing nothing useful #1040

bukzor opened this issue Dec 19, 2017 · 3 comments

Comments

@bukzor
Copy link
Contributor

bukzor commented Dec 19, 2017

When I profile a hypothesis run (with use_coverage off), I see that 11% of the time is taken by hypothesis.internal.conjecture.engine:398:debug_data. Looking more closely, this function takes time generating data for the debugging log, even when that log is turned off. Let's please make this more lazy.

A very simple (but not elegant) solution is:

--- hypothesis/internal/conjecture/engine.py
+++ hypothesis/internal/conjecture/engine.py
@@ -26,6 +26,7 @@ from collections import defaultdict
 import attr
 
 from hypothesis import settings as Settings
+from hypothesis import Verbosity
 from hypothesis import Phase, HealthCheck
 from hypothesis.reporting import debug_report
 from hypothesis.internal.compat import EMPTY_BYTES, Counter, ceil, \
@@ -396,6 +397,8 @@ class ConjectureRunner(object):
             debug_report(message)
 
     def debug_data(self, data):
+        if self.settings.verbosity < Verbosity.debug:
+          return
         buffer_parts = [u"["]
         for i, (u, v) in enumerate(data.blocks):
             if i > 0:
@Zac-HD
Copy link
Member

Zac-HD commented Dec 19, 2017

Hmm. I've just traced this through, and we could pass a thunk to make string construction lazy. I tend to think though that with only two calls it's more elegant just to check verbosity before calling the method. I'll open a pull.

@bukzor
Copy link
Contributor Author

bukzor commented Dec 19, 2017

Thanks! I'm eagerly awaiting.

@bukzor
Copy link
Contributor Author

bukzor commented Jan 19, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants