gpt4 book ai didi

c - 我的应用程序在 linux c 中的 cpu 使用情况

转载 作者:太空狗 更新时间:2023-10-29 12:14:07 25 4
gpt4 key购买 nike

我想查找我自己的 c 应用程序的 CPU 使用率。我已经使用了 ps -p pid -o %cpu,%mem,cmd 它在我的 Ubuntu 10.04 桌面上运行良好。但不适用于 ARM 架构。

它显示以下错误。

ps: invalid option -- 'p'

BusyBox v1.13.2 (2011-03-24 18:58:44 CDT) multi-call binary

Usage: ps

Report process status

Options: w Wide output

所以我需要 c 代码来查找 cpu 使用情况。

最佳答案

Busybox 是一组占用空间很小的工具,它只包含桌面系统中最有用的功能子集。

要获得更完整的 ps,您可能需要使用 http://procps.sourceforge.net/ 中的 ps

您可能想要替换 busybox 中的 ps,或者如果您的程序具有 GPL 兼容许可证,您可以从 procps 中获取 C 源代码片段。

关于c - 我的应用程序在 linux c 中的 cpu 使用情况,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31748990/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com