MCPcopy Create free account
hub / github.com/1jehuang/jcode / finalize

Method finalize

scripts/profile_spawn.py:231–268  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

229 return True
230
231 def finalize(self) -> ResourceProfile:
232 p = ResourceProfile()
233 p.wall_ms = (self.end - self.start) * 1000.0
234 p.samples = self.n
235 p.peak_rss_bytes = self.peak_rss
236 p.peak_rss_anon_bytes = self.peak_rss_anon
237 p.peak_pss_bytes = self.peak_pss
238 p.peak_swap_bytes = self.peak_swap
239 p.peak_threads = self.peak_threads
240 p.peak_fds = self.peak_fds
241 if self.last:
242 p.final_rss_bytes = self.last.rss_bytes or 0
243 l = self.last
244 if l:
245 # Cumulative counters in /proc are totals since process birth. We
246 # monitor from spawn, so the final absolute value IS the total
247 # resource cost of the spawn (more robust than last-first, which
248 # would miss work done before the first sample landed).
249 if l.utime_s is not None:
250 p.cpu_user_s = l.utime_s
251 if l.stime_s is not None:
252 p.cpu_sys_s = l.stime_s
253 p.cpu_total_s = p.cpu_user_s + p.cpu_sys_s
254 if p.wall_ms > 0:
255 p.cpu_pct = 100.0 * p.cpu_total_s / (p.wall_ms / 1000.0)
256 if l.minflt is not None:
257 p.minflt = l.minflt
258 if l.majflt is not None:
259 p.majflt = l.majflt
260 if l.vol_ctxt is not None:
261 p.vol_ctxt = l.vol_ctxt
262 if l.nonvol_ctxt is not None:
263 p.nonvol_ctxt = l.nonvol_ctxt
264 if l.read_bytes is not None:
265 p.io_read_bytes = l.read_bytes
266 if l.write_bytes is not None:
267 p.io_write_bytes = l.write_bytes
268 return p
269
270
271# --------------------------------------------------------------------------- #

Callers 3

profile_server_spawnFunction · 0.95
profile_client_spawnFunction · 0.95
sha256_fileFunction · 0.45

Calls 1

ResourceProfileClass · 0.85

Tested by

no test coverage detected