编程之美1.1多核CPU
来源:互联网 发布:淘宝开抢软件 编辑:程序博客网 时间:2024/05/04 19:57
方波 sin波 直线 // ==================【控制cpu曲线】=================// @ author : zhyh2010// @ date : 20150609// @ version : 1.0// @ description : 核心: 在任务管理器的一个刷新周期内// CPU 忙的时间 和 刷新时间的比率就是 CPU 的占用率// CPU 显示的实际只是一个平均值// ================【end of 控制cpu曲线】===============#include <stdlib.h>#include <stdio.h>#include <windows.h>#include <math.h>// void busy1()// {// for (int i = 0; i != 10; i++)// {// system("start calc");// }// system("taskkill /f /im calc.exe");// printf("busy\n");// }void DrawSin(){ system("title sin"); const float PI = 3.1415926535; const int count = 360; const int GAP = 1; const DWORD totalTime = 200; float x = 0; float ratio[count] = { 0 }; for (int i = 0; i != count; i++, x += GAP) ratio[i] = 0.5 * sin(PI * x / 180.0); for (int i = 0; TRUE; i = (i + 1) % count) { DWORD startTime = GetTickCount(); while (GetTickCount() - startTime < (0.5 + ratio[i]) * totalTime); Sleep((0.5 - ratio[i]) * totalTime); }}void DrawLinear(float ratio = 0.9){ system("title drawline"); const DWORD totalTime = 200; while (true) { DWORD startTime = GetTickCount(); while (GetTickCount() - startTime < ratio * totalTime); Sleep((1 - ratio) * totalTime); } }void DrawSquareWave(float max = 0.9, float min = 0.1){ system("title squareWave"); const DWORD totalTime = 200; const int count = 300; for (int i = 0; TRUE; i = (i + 1) % count) { float ratio = (i > count / 2) ? max : min; DWORD startTime = GetTickCount(); while (GetTickCount() - startTime < ratio * totalTime); Sleep((1 - ratio) * totalTime); }}void main(){ // ===============【设置进程所在cpu】================= SetProcessAffinityMask(GetCurrentProcess(), 1); DrawLinear(); //DrawSin(); //DrawSquareWave();}
0 0
- 编程之美1.1多核CPU
- 编程之美中CPU运行曲线题目(多核版本)
- 编程之美 1.1 让cpu占用率曲线听你指挥(多核处理器)
- 编程之美 1.1 让cpu占用率曲线听你指挥(多核处理器)
- 让多核CPU占用率曲线听你指挥(Windows实现)——《编程之美》1.1学习笔记
- 让多核CPU占用率曲线听你指挥(Linux实现)——《编程之美》1.1继续学习
- 让多核CPU占用率曲线听你指挥(Linux实现)——《编程之美》1.1继续学习
- 如何让多核cpu跑出sin曲线,来自编程之美
- 编程之美 1.1、CPU占用率
- CPU正弦曲线【编程之美】
- 编程之美-CPU占用率
- Day1 编程之美之1.1-控制CPU占有率
- 编程之美解题报告-1.1 50%CPU曲线
- 编程之美-1.1、cpu占用率保持到50%
- 让CPU使用为正弦曲线-编程之美1.1实现
- 《编程之美》之CPU曲线
- 读编程之美:CPU占用率
- 编程之美--让CPU显示正弦曲线
- Apache
- C#多个版本的比较排序差距
- 串口控制台
- 离散题目15
- 类型转换符
- 编程之美1.1多核CPU
- 高中数学?
- git初次搭建博客
- 求排列的逆序数
- HDU 1087 Super Jumping! Jumping! Jumping!【最长上升子序列元素总和】
- 去哪网笔试 最短路径算法(词梯) Java实现
- AccessController.doPrivileged
- 什么是JDK API
- Swing绘图API