소스 검색

提升CPU的功能

master
PoffyZhang 1 년 전
부모
커밋
c365d81ea4
2개의 변경된 파일94개의 추가작업 그리고 0개의 파일을 삭제
  1. +51
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/sys/controller/CpuController.java
  2. +43
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/sys/manage/CpuManage.java

+ 51
- 0
pmapi/src/main/java/com/ningdatech/pmapi/sys/controller/CpuController.java 파일 보기

@@ -0,0 +1,51 @@
package com.ningdatech.pmapi.sys.controller;

import com.ningdatech.log.annotation.WebLog;
import com.ningdatech.pmapi.sys.manage.CpuManage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
* @Classname CpuController
* @Description
* @Date 2023/10/30 11:06
* @Author PoffyZhang
*/
@Slf4j
@Validated
@RestController
@RequestMapping("/api/v1/cpu")
@Api(value = "CpuController", tags = "CPU提升和关闭提升")
@RequiredArgsConstructor
public class CpuController {

private final CpuManage cpuManage;

@ApiOperation(value = "CPU初始化任务", notes = "CPU初始化任务")
@PostMapping("/start")
@WebLog("CPU初始化任务")
public String start() {
cpuManage.whileTrueTask();
return "初始化成功";
}

@ApiOperation(value = "提升CPU", notes = "提升CPU")
@PostMapping("/high/{cpu}")
@WebLog("提升CPU")
public String high(@PathVariable Integer cpu) {
cpuManage.open(cpu);
return "提高成功";
}

@ApiOperation(value = "关闭CPU任务", notes = "关闭CPU任务")
@PostMapping("/close")
@WebLog("关闭CPU任务")
public String close() {
cpuManage.close();
return "关闭成功";
}
}

+ 43
- 0
pmapi/src/main/java/com/ningdatech/pmapi/sys/manage/CpuManage.java 파일 보기

@@ -0,0 +1,43 @@
package com.ningdatech.pmapi.sys.manage;

import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
* @Classname CpuManage
* @Description
* @Date 2023/8/7 9:25
* @Author PoffyZhang
*/
@Component
@AllArgsConstructor
@Slf4j
public class CpuManage {

private volatile Boolean isOpen = Boolean.FALSE;

private int[][] matrix = new int[1][1];

public void open(int i){
Double pow = Math.pow(10, i);
matrix = new int[pow.intValue()][pow.intValue()];
this.isOpen = Boolean.TRUE;
}

public void close(){
matrix = new int[1][1];
this.isOpen = Boolean.FALSE;
}

public void whileTrueTask(){
while (isOpen) {
// 这个循环会一直运行,直到程序被停止
for (int i = 0; i < matrix.length; i++) {
for (int j = 0; j < matrix[i].length; j++) {
matrix[i][j] = i * j;
}
}
}
}
}

불러오는 중...
취소
저장