Commits (4)
......@@ -93,8 +93,9 @@ def compare_files(file1, file2, source=None, diff_content_only=False):
# Specialize the files first so "has_same_content_as" can be overridden
# by subclasses
specialize(file1)
specialize(file2)
with profile("specialize", "specialize"):
specialize(file1)
specialize(file2)
force_details = Config().force_details
with profile("has_same_content_as", file1):
......
......@@ -32,6 +32,7 @@ from multiprocessing.dummy import Queue
from .tools import get_tool_name, tool_required
from .config import Config
from .profiling import profile
from .tempfiles import get_temporary_directory
DIFF_CHUNK = 4096
......@@ -386,7 +387,7 @@ def color_unified_diff(diff):
DIFFON = "\x01"
DIFFOFF = "\x02"
MAX_WAGNER_FISCHER_SIZE = (
1024 # any higher, and linediff takes >1 second and >200MB RAM
256 # any higher, and linediff takes >1 second and >200MB RAM
)
......@@ -450,6 +451,7 @@ def linediff_wagnerfischer(s, t):
for j in range(1, n + 1):
d[0][j] = (j, (0, j - 1))
# NB. This loop is O(len(s) * len(t))
for i in range(1, m + 1):
for j in range(1, n + 1):
if s[i - 1] == t[j - 1]:
......@@ -611,7 +613,8 @@ class SideBySideDiff:
type_name = "unmodified"
else:
type_name = "changed"
s1, s2 = linediff(s1, s2, self.diffon, self.diffoff)
with profile("diff", "linediff"):
s1, s2 = linediff(s1, s2, self.diffon, self.diffoff)
yield "L", (type_name, s1, self.line1, s2, self.line2)
......
......@@ -16,9 +16,11 @@
# You should have received a copy of the GNU General Public License
# along with diffoscope. If not, see <https://www.gnu.org/licenses/>.
import os
import logging
from ..profiling import profile
from ..utils import format_bytes
from .text import TextPresenter
from .json import JSONPresenter
......@@ -102,6 +104,17 @@ class PresenterManager:
with profile("output", name):
data["klass"].run(data, difference, parsed_args)
size = "n/a"
if os.path.isfile(data["target"]):
size = format_bytes(os.path.getsize(data["target"]))
logger.debug(
"Generated %r output at %r (size: %s)",
name,
data["target"],
size,
)
def compute_visual_diffs(self):
"""
Don't waste time computing visual differences if we won't use them.
......