MCPcopy Create free account
hub / github.com/aws/aws-cli / _run_benchmark

Method _run_benchmark

scripts/performance/benchmark_utils.py:235–264  ·  view source on GitHub ↗
(self, pid, data_interval)

Source from the content-addressed store, hash-verified

233 raise
234
235 def _run_benchmark(self, pid, data_interval):
236 process_to_measure = psutil.Process(pid)
237 samples = []
238
239 while process_to_measure.is_running():
240 if process_to_measure.status() == psutil.STATUS_ZOMBIE:
241 break
242 time.sleep(data_interval)
243 try:
244 # Collect the memory and cpu usage.
245 memory_used = process_to_measure.memory_info().rss
246 cpu_percent = process_to_measure.cpu_percent()
247 except (
248 psutil.AccessDenied,
249 psutil.ZombieProcess,
250 psutil.NoSuchProcess,
251 ):
252 # Trying to get process information from a closed or
253 # zombie process will result in corresponding exceptions.
254 break
255 # Determine the lapsed time for bookkeeping
256 current_time = time.time()
257 samples.append(
258 {
259 "time": current_time,
260 "memory": memory_used,
261 "cpu": cpu_percent,
262 }
263 )
264 return samples
265
266
267class BenchmarkHarness:

Callers 1

benchmark_processMethod · 0.95

Calls 3

statusMethod · 0.80
sleepMethod · 0.45
timeMethod · 0.45

Tested by

no test coverage detected