MCPcopy Create free account
hub / github.com/Project-OSRM/osrm-backend / run

Function run

scripts/routed_benchmark.py:100–144  ·  view source on GitHub ↗
(args)

Source from the content-addressed store, hash-verified

98
99
100def 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
147def make_csv(args):

Callers

nothing calls this directly

Calls 9

make_requestMethod · 0.95
rangeClass · 0.85
zip_longestFunction · 0.85
ClientClass · 0.85
existsMethod · 0.80
joinMethod · 0.80
killMethod · 0.80
teeFunction · 0.70
reportFunction · 0.70

Tested by

no test coverage detected