Skip to content

Commit

Permalink
python: Replaced difflib based scalar file comparison with command li…
Browse files Browse the repository at this point in the history
…ne diff tool.

The Python version was running for hours for a 10MB file while the
command line version returns basically immediately.
  • Loading branch information
levy committed Jan 15, 2024
1 parent 49c0a92 commit bddfb48
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions python/inet/test/statistical.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
https://github.com/inet-framework/statistics in a separate GitHub repository.
"""

import difflib
import glob
import logging
import math
import pandas
import re
import shutil
import subprocess

from omnetpp.scave.results import *

Expand All @@ -31,13 +31,9 @@ def _read_scalar_result_file(file_name):
return df

def _write_diff_file(a_file_name, b_file_name, diff_file_name):
with open(a_file_name, "r") as file:
a_file = file.readlines()
with open(b_file_name, "r") as file:
b_file = file.readlines()
diff_command = ["diff", a_file_name, b_file_name]
with open(diff_file_name, "w") as file:
diff = "".join(difflib.unified_diff(a_file, b_file))
file.write(diff)
subprocess.call(diff_command, stdout=file)

class StatisticalTestTask(SimulationTestTask):
def __init__(self, simulation_config=None, run_number=0, name="statistical test", task_result_class=SimulationTestTaskResult, **kwargs):
Expand Down

0 comments on commit bddfb48

Please sign in to comment.