MCPcopy Create free account
hub / github.com/AdaCompNUS/summit / run_benchmark

Function run_benchmark

PythonAPI/util/performance_benchmark.py:314–359  ·  view source on GitHub ↗
(world, sensors, n_vehicles, n_walkers, client, debug=False)

Source from the content-addressed store, hash-verified

312# ======================================================================================================================
313
314def run_benchmark(world, sensors, n_vehicles, n_walkers, client, debug=False):
315 global sensors_callback
316
317 spawn_points = world.get_map().get_spawn_points()
318 n = min(n_vehicles, len(spawn_points))
319 list_fps = []
320 sensor_list = None
321
322 vehicles_list, walkers_list, all_id, all_actors, sensors_ret = create_environment(world, sensors, n, n_walkers, spawn_points, client)
323
324 if sensors_ret:
325 sensor_list = sensors_ret
326
327 ticks = 0
328 while ticks < args.ticks:
329 _ = world.wait_for_tick()
330 if debug:
331 print("== Samples {} / {}".format(ticks + 1, args.ticks))
332
333 min_fps = float('inf')
334 for sc in sensors_callback:
335 fps = sc.get_fps()
336 if fps < min_fps:
337 min_fps = fps
338 if math.isinf(min_fps):
339 min_fps = 0
340 list_fps.append(min_fps)
341
342 ticks += 1
343
344 for sensor in sensor_list:
345 sensor.stop()
346 sensor.destroy()
347 sensors_callback.clear()
348
349 print('Destroying %d vehicles.\n' % len(vehicles_list))
350 client.apply_batch([carla.command.DestroyActor(x) for x in vehicles_list])
351
352 # stop walker controllers (list is [controller, actor, controller, actor ...])
353 for i in range(0, len(all_id), 2):
354 all_actors[i].stop()
355
356 print('\ndestroying %d walkers' % len(walkers_list))
357 client.apply_batch([carla.command.DestroyActor(x) for x in all_id])
358
359 return list_fps
360
361
362def compute_mean_std(list_values):

Callers 1

mainFunction · 0.85

Calls 6

create_environmentFunction · 0.85
get_fpsMethod · 0.80
clearMethod · 0.80
appendMethod · 0.45
destroyMethod · 0.45
DestroyActorMethod · 0.45

Tested by

no test coverage detected