Compare commits

...

5 Commits

Author SHA1 Message Date
AleksanovED 1e03179ca5 завел .gitignore 2025-03-06 10:55:17 +03:00
AleksanovED 9156f36ac6 rename 2025-03-06 10:49:56 +03:00
AleksanovED 1036cade95 перенос файликов 2025-03-06 10:45:42 +03:00
AleksanovED 337c428ebd реализация 2025-03-06 03:59:00 +03:00
AleksanovED 804e6b6daa реализация my_start и my_fin 2025-03-06 03:48:00 +03:00
7 changed files with 203 additions and 0 deletions

38
.gitignore vendored Normal file
View File

@ -0,0 +1,38 @@
# Игнорировать бинарные файлы
*.exe
*.out
*.app
*.o
*.a
*.so
*.dll
*.dylib
# Игнорировать папку .vscode
.vscode/
# Игнорировать сгенерированные файлы
build/
bin/
obj/
# Игнорировать системные файлы
.DS_Store
Thumbs.db
# Игнорировать файлы проекта IDE
*.sln
*.vcxproj
*.vcxproj.filters
*.vcxproj.user
# Игнорировать временные файлы
*.swp
*.swo
*~
*.bak
# Игнорировать логи и результаты тестов
*.log
*.tmp
test-results/

67
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,67 @@
{
"files.associations": {
"algorithm": "cpp",
"atomic": "cpp",
"bit": "cpp",
"cctype": "cpp",
"charconv": "cpp",
"chrono": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"compare": "cpp",
"concepts": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"exception": "cpp",
"format": "cpp",
"forward_list": "cpp",
"initializer_list": "cpp",
"iomanip": "cpp",
"ios": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"iterator": "cpp",
"limits": "cpp",
"locale": "cpp",
"map": "cpp",
"memory": "cpp",
"mutex": "cpp",
"new": "cpp",
"optional": "cpp",
"ostream": "cpp",
"ratio": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"stop_token": "cpp",
"streambuf": "cpp",
"string": "cpp",
"system_error": "cpp",
"thread": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"typeinfo": "cpp",
"utility": "cpp",
"vector": "cpp",
"xfacet": "cpp",
"xiosbase": "cpp",
"xlocale": "cpp",
"xlocbuf": "cpp",
"xlocinfo": "cpp",
"xlocmes": "cpp",
"xlocmon": "cpp",
"xlocnum": "cpp",
"xloctime": "cpp",
"xmemory": "cpp",
"xstddef": "cpp",
"xstring": "cpp",
"xtr1common": "cpp",
"xtree": "cpp",
"xutility": "cpp"
}
}

13
src/Makefile Normal file
View File

@ -0,0 +1,13 @@
CXX = g++
CXXFLAGS = -Iinclude/
all: my_app
my_app:
$(CXX) $(CXXFLAGS) ./my_start.cpp ./my_fin.cpp ./main.cpp -o my_app
rebuild:
rm -f my_app && make my_app
clean:
rm -f my_app

22
src/main.cpp Normal file
View File

@ -0,0 +1,22 @@
#include <iostream>
#include <thread>
#include <chrono>
#include "my_start.hpp"
int main() {
my_start();
for (int i = 0; i < 5; ++i) {
std::this_thread::sleep_for(std::chrono::seconds(25));
if (i % 2 == 0) {
n_ok_requests++;
} else {
n_fail_requests++;
}
}
my_fin();
return 0;
}

34
src/my_fin.cpp Normal file
View File

@ -0,0 +1,34 @@
#include "my_start.hpp"
#include <cstdlib>
void my_fin() {
auto end_timestamp = std::chrono::system_clock::now();
auto end_time_t = std::chrono::system_clock::to_time_t(end_timestamp);
auto end_ms = std::chrono::duration_cast<std::chrono::milliseconds>(end_timestamp.time_since_epoch()) % 1000;
auto duration = end_timestamp - start_timestamp;
auto hours = std::chrono::duration_cast<std::chrono::hours>(duration);
auto minutes = std::chrono::duration_cast<std::chrono::minutes>(duration % std::chrono::hours(1));
auto seconds = std::chrono::duration_cast<std::chrono::seconds>(duration % std::chrono::minutes(1));
auto milliseconds = std::chrono::duration_cast<std::chrono::milliseconds>(duration % std::chrono::seconds(1));
std::cout << "Worked for ";
if (duration < std::chrono::minutes(2)) {
double total_seconds = std::chrono::duration<double>(duration).count();
std::cout << std::fixed << std::setprecision(3) << total_seconds << " seconds";
} else {
if (hours.count() > 0) std::cout << hours.count() << "h ";
if (minutes.count() > 0) std::cout << minutes.count() << "m ";
std::cout << seconds.count() << "s " << milliseconds.count() << "ms";
}
std::cout << std::endl;
std::cout << "Sent " << (n_ok_requests + n_fail_requests) << " requests ("
<< n_ok_requests << " ok, " << n_fail_requests << " failed)" << std::endl;
std::cout << "DosAtk stopped at " << std::put_time(std::localtime(&end_time_t), "%Y-%m-%d %H:%M:%S")
<< "." << std::setfill('0') << std::setw(3) << end_ms.count() << std::endl;
std::exit(0);
}

18
src/my_start.cpp Normal file
View File

@ -0,0 +1,18 @@
#include "my_start.hpp"
int n_ok_requests = 0;
int n_fail_requests = 0;
std::chrono::system_clock::time_point start_timestamp;
void my_start() {
n_ok_requests = 0;
n_fail_requests = 0;
start_timestamp = std::chrono::system_clock::now();
auto now = std::chrono::system_clock::now();
auto now_time_t = std::chrono::system_clock::to_time_t(now);
auto now_ms = std::chrono::duration_cast<std::chrono::milliseconds>(now.time_since_epoch()) % 1000;
std::cout << "Starting DosAtk at " << std::put_time(std::localtime(&now_time_t), "%Y-%m-%d %H:%M:%S")
<< "." << std::setfill('0') << std::setw(3) << now_ms.count() << std::endl;
}

11
src/my_start.hpp Normal file
View File

@ -0,0 +1,11 @@
#include <iostream>
#include <chrono>
#include <iomanip>
#include <ctime>
void my_start();
void my_fin();
extern int n_ok_requests;
extern int n_fail_requests;
extern std::chrono::system_clock::time_point start_timestamp;