delphi 获取当前进程的cpu占用率
TProcessCpuUsage = record
private
FLastUsed, FLastTime: Int64;
FCpuCount:Integer;
public
class function Create: TProcessCpuUsage; static;
function Current: Single;
end;
var
ProcessCpuUsage: TProcessCpuUsage = (FLastUsed: 0; FLastTime: 0;FCpuCount:0);
begin
Result.FLastTime := 0;
Result.FLastUsed := 0;
Result.FCpuCount := 0;
end;
var
Usage, ACurTime: UInt64;
CreateTime, ExitTime, IdleTime, UserTime, KernelTime: TFileTime;
function FileTimeToI64(const ATime: TFileTime): Int64;
begin
Result := (Int64(ATime.dwHighDateTime) shl 32) + ATime.dwLowDateTime;
end;
function GetCPUCount: Integer;
var
SysInfo: TSystemInfo;
begin
GetSystemInfo(SysInfo);
Result := SysInfo.dwNumberOfProcessors;
end;
Result := 0;
if GetProcessTimes(GetCurrentProcess, CreateTime, ExitTime, KernelTime,
UserTime) then
begin
ACurTime := GetTickCount;
Usage := FileTimeToI64(UserTime) + FileTimeToI64(KernelTime);
if FLastTime <> 0 then
Result := (Usage - FLastUsed) / (ACurTime - FLastTime) /
FCpuCount / 100
else
FCpuCount:=GetCpuCount;
FLastUsed := Usage;
FLastTime := ACurTime;
end;
end;
if ProcessCpuUsage.Current >= 25 then
begin
............................
end
http://blog.csdn.net/y281252548/article/details/50600028
delphi 获取当前进程的cpu占用率的更多相关文章
- Linux环境下进程的CPU占用率
阿里云服务器网站:https://promotion.aliyun.com/ntms/yunparter/invite.html?userCode=qqwovx6h 文字来源:http://www.s ...
- linux下如何获取每个线程的CPU占用率
啥也不说,直接上脚本: root@Storage:/mnt/mtd# cat cpu.sh #!/bin/sh while truedo ps -H -eo user,pid,ppid, ...
- Linux下如何查看高CPU占用率线程
转于:http://www.cnblogs.com/lidabo/p/4738113.html 目录(?)[-] proc文件系统 proccpuinfo文件 procstat文件 procpidst ...
- Linux下如何查看高CPU占用率线程 LINUX CPU利用率计算
目录(?)[-] proc文件系统 proccpuinfo文件 procstat文件 procpidstat文件 procpidtasktidstat文件 系统中有关进程cpu使用率的常用命令 ps ...
- c++ 计算cpu占用率
计算CPU占用率就是获取系统总的内核时间 用户时间及空闲时间 其中空闲时间就是内核空转 所以内核时间包含空闲时间 然后计算 运行时间 = 内核时间 加 用户时间 减去 空闲时间 间隔时间 = 内核时 ...
- 使用 nice、cpulimit 和 cgroups 限制 cpu 占用率
Linux内核是一名了不起的马戏表演者,它在进程和系统资源间小心地玩着杂耍,并保持系统的能够正常运转. 同时,内核也很公正:它将资源公平地分配给各个进程. 但是,如果你需要给一个重要进程提高优先级时, ...
- 查看Windows下引起Oracle CPU占用率高的神器-qslice
前言: qslice是一个win2000的工具包,能分析进程的cpu占用率,我们用于分析oracle的性能 这是绿色的软件无需安装. 我们经常会碰到oracle的CPU占用居高不下,无法快速定位到问题 ...
- CPU占用率高分析方法步骤[转载]
由于涉及到私有代码,所有图片都隐去 1.执行TOP命令,确认CPU占用较高的进程PID 根据top命令,发现PID为8691的Java进程占用CPU高达3858%,出现故障 2.确认该进程中CPU占用 ...
- (笔记)Linux下如何查看高CPU占用率线程
在 Linux 下 top 工具可以显示 cpu 的平均利用率(user,nice,system,idle,iowait,irq,softirq,etc.),可以显示每个 cpu 的利用率.但是无法显 ...
随机推荐
- findbugs静态代码分析工具使用教程
FindBugs 是一个静态分析工具,很多程序猿都在使用,再次详细列出findbugs的使用教程,希望对大家有帮助. 1 安装 FindBugs通过检查类文件或 JAR文件,将字节码与一组缺陷模式进行 ...
- prettytensor 的使用
prettytensor 顾名思义,对原始的 tensorflow 下的 tensor 进行封装(prettytensor 以 tensorflow 为基础,二者搭配使用),使其成为一个更为接口友好的 ...
- 【序列操作IV】树状数组套线段树/树套树
题目描述 给出序列 a1,a2,…,an(0≤ai≤109),有关序列的两种操作. 1. ai(1≤i≤n)变成 x(0≤x≤109). 2. 求 al,al+1,…,ar(1≤l≤r≤n)第 k(1 ...
- [Example of Sklearn] - Example
reference : http://my.oschina.net/u/175377/blog/84420 目录[-] Scikit Learn: 在python中机器学习 载入示例数据 一个改变数据 ...
- Array类型判断
http://www.cnblogs.com/YaoAzhen/archive/2010/01/27/1657696.html
- Project Euler:Problem 28 Number spiral diagonals
Starting with the number 1 and moving to the right in a clockwise direction a 5 by 5 spiral is forme ...
- Linux下如何生成core dump 文件(解决segment fault段错误的问题)
Linux下的C程序常常会因为内存访问等原因造成segment fault(段错误),如果此时core dump 的功能是打开的,在运行我们的可执行程序时就会生成一个名为core的文件,然后我们就可以 ...
- Java transient关键字【转】
转自:http://www.blogjava.net/fhtdy2004/archive/2009/06/20/286112.htmlVolatile修饰的成员变量在每次被线程访问时,都强迫从主内存中 ...
- Android 事件分发机制具体解释
很多其它内容请參照我的个人网站: http://stackvoid.com/ 网上非常多关于Android事件分发机制的解释,大多数描写叙述的都不够清晰,没有吧来龙去脉搞清晰,本文将带你从Touch事 ...
- StreamDM:基于Spark Streaming、支持在线学习的流式分析算法引擎
StreamDM:基于Spark Streaming.支持在线学习的流式分析算法引擎 streamDM:Data Mining for Spark Streaming,华为诺亚方舟实验室开源了业界第一 ...