diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2022-11-20 09:45:01 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2022-11-20 10:58:33 -0500 |
commit | 1cd6c9bba0b4ba3018bf1b28fee645a7dd98fe68 (patch) | |
tree | 2e5e19653ad2d215a9f02758c18ade54d08f357d /coverage/sqldata.py | |
parent | 66c45143008366726293a341405d45a3a8e9ed87 (diff) | |
download | python-coveragepy-git-1cd6c9bba0b4ba3018bf1b28fee645a7dd98fe68.tar.gz |
perf: more combine speed-ups
By avoiding writing metadata that differs but doesn't change the data,
we get a higher hitrate on the hash-checking when combining.
Use --debug=process to include these details for debugging.
Diffstat (limited to 'coverage/sqldata.py')
-rw-r--r-- | coverage/sqldata.py | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/coverage/sqldata.py b/coverage/sqldata.py index 2fbc53f5..ea6b1199 100644 --- a/coverage/sqldata.py +++ b/coverage/sqldata.py @@ -4,6 +4,7 @@ """SQLite coverage data.""" import collections +import datetime import functools import glob import itertools @@ -51,10 +52,11 @@ CREATE TABLE meta ( key text, value text, unique (key) - -- Keys: + -- Possible keys: -- 'has_arcs' boolean -- Is this data recording branches? -- 'sys_argv' text -- The coverage command line that recorded the data. -- 'version' text -- The version of coverage.py that made the file. + -- 'when' text -- Datetime when the file was created. ); CREATE TABLE file ( @@ -298,13 +300,18 @@ class CoverageData(SimpleReprMixin): self._debug.write(f"Initing data file {self._filename!r}") db.executescript(SCHEMA) db.execute("insert into coverage_schema (version) values (?)", (SCHEMA_VERSION,)) - db.executemany( - "insert or ignore into meta (key, value) values (?, ?)", - [ + + # When writing metadata, avoid information that will needlessly change + # the hash of the data file, unless we're debugging processes. + meta_data = [ + ("version", __version__), + ] + if self._debug.should("process"): + meta_data.extend([ ("sys_argv", str(getattr(sys, "argv", None))), - ("version", __version__), - ] - ) + ("when", datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")), + ]) + db.executemany("insert or ignore into meta (key, value) values (?, ?)", meta_data) def _connect(self): """Get the SqliteDb object to use.""" |