跟踪 Chrome 及其许多进程
我试图密切关注应用程序的运行时间。为此,我在每个进程启动时捕获其 ID,并在该进程关闭时记录时间。然而,当您启动和关闭 Google 的 Chrome 时,它会启动和停止 6 个进程,这意味着 Chrome 的每次执行都会被记录多次。
有没有比进程 ID 更好的方法来跟踪应用程序的执行情况?或者是否有一种技术可以解决这个特定问题?如果在一秒左右的时间内添加具有相同 ID 的进程,我曾考虑过不添加进程 ID,但这似乎是可利用的。
有什么想法吗?
I'm trying to keep an eye on how long an application runs. To do this, I capture every process's ID as it starts, and when that process is shut down, I log the time. However, Google's Chrome starts and stops like 6 processes when you start it up and shut it down, meaning each execution of Chrome gets logged multiple times.
Is there a better way to track the execution of an application than by process ID? Or is there, perhaps, a technique for getting around this particular problem? I'd considered not adding a process ID if a process with the same ID was added within a second or so, but that seems exploitable.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不是 100%,但我认为 Chrome 中的一个进程必须是父进程。如果进程的父进程 (PPID) 相同(并且不是 init = PID 1),请尝试从列表中删除进程
I am not 100% but I would assume that one process in Chrome must be the parent. try eliminating processes from your list if their parent (PPID) is the same (and not init = PID 1)
我最终只是检查是否添加了重复项。效率不是很高,但是简单有效。暂时可以使用。
I ended up just checking if I was adding a duplicate. Not very efficient, but easy and effective. It will serve for now.