Compare commits
2 Commits
66f7ae790d
...
5172a991cd
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5172a991cd | ||
|
|
7a722ba478 |
24
.gitea/workflows/qwe.yml
Normal file
24
.gitea/workflows/qwe.yml
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
name: Compile and Run C++
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "main", "master" ]
|
||||
pull_request:
|
||||
branches: [ "main", "master" ]
|
||||
|
||||
jobs:
|
||||
build-and-test:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Check out repository code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install GCC
|
||||
run: sudo apt-get update && sudo apt-get install -y g++
|
||||
|
||||
- name: Compile C++ program
|
||||
run: g++ -o qweq qweq.cpp
|
||||
|
||||
- name: Run program
|
||||
run: ./qweq
|
||||
33
qweq.cpp
Normal file
33
qweq.cpp
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
#include <iostream>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
#include <chrono>
|
||||
#include <atomic>
|
||||
|
||||
std::atomic<bool> running{true};
|
||||
|
||||
void cpu_burner() {
|
||||
while (true) {
|
||||
volatile double x = 1.0;
|
||||
for (int i = 0; i < 1000000; ++i) {
|
||||
x += x * 0.000001;
|
||||
x -= x * 0.000001;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
int cores = std::thread::hardware_concurrency();
|
||||
if (cores == 0) cores = 4;
|
||||
std::vector<std::thread> threads;
|
||||
for (int i = 0; i < cores; ++i) {
|
||||
threads.emplace_back(cpu_burner);
|
||||
}
|
||||
|
||||
|
||||
for (auto& t : threads) {
|
||||
t.join();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user