(args)
| 98 | |
| 99 | |
| 100 | def run(args): |
| 101 | for logfile in args.logfiles: |
| 102 | path = pathlib.Path(logfile) |
| 103 | if path.exists(): |
| 104 | file_time = datetime.datetime.fromtimestamp(path.stat().st_ctime) |
| 105 | new_name = path.with_suffix(".log." + file_time.isoformat()) |
| 106 | path.rename(new_name) |
| 107 | |
| 108 | for n in range(0, args.runs): |
| 109 | for build, logfile, dataset in zip_longest( |
| 110 | args.builds, args.logfiles, args.datasets |
| 111 | ): |
| 112 | with open(logfile, "a") as log: |
| 113 | |
| 114 | def tee(text): |
| 115 | if text != ".\n": |
| 116 | print(text, end="") |
| 117 | log.write(text) |
| 118 | log.flush() |
| 119 | |
| 120 | client = Client(args) |
| 121 | |
| 122 | binary = os.path.join(build, "osrm-routed") |
| 123 | proc = subprocess.Popen( |
| 124 | [binary, "-a", "CH", dataset], |
| 125 | stdout=subprocess.PIPE, |
| 126 | stderr=subprocess.STDOUT, |
| 127 | text=True, |
| 128 | ) |
| 129 | tee(f'### {n} "{binary}" "{logfile}"\n') |
| 130 | left = args.run_length |
| 131 | ready = False |
| 132 | random.seed(69) |
| 133 | while left > 0 and proc.poll() is None: |
| 134 | if ready: |
| 135 | client.make_request() |
| 136 | left -= 1 |
| 137 | text = proc.stdout.readline() |
| 138 | if not ready and "running" in text: |
| 139 | ready = True |
| 140 | tee(text) |
| 141 | tee(f"Distance: {client.distance}\n") |
| 142 | # log.write(text) |
| 143 | proc.kill() |
| 144 | report(args) |
| 145 | |
| 146 | |
| 147 | def make_csv(args): |
nothing calls this directly
no test coverage detected