mirror of
https://gitea.sffempire.ru/Kolyah35/minecraft-pe-0.6.1.git
synced 2026-03-20 06:53:30 +00:00
ADD: lastip
This commit is contained in:
@@ -10,12 +10,12 @@
|
||||
#define TIMER_PUSH(x) PerfTimer::push(x)
|
||||
#define TIMER_POP() PerfTimer::pop()
|
||||
#define TIMER_POP_PUSH(x) PerfTimer::popPush(x)
|
||||
#elif defined(SERVER_PROFILER)
|
||||
#include "ServerProfiler.h"
|
||||
// #elif defined(SERVER_PROFILER)
|
||||
// #include "ServerProfiler.h"
|
||||
|
||||
#define TIMER_PUSH(x) ServerProfiler::push(x)
|
||||
#define TIMER_POP() ServerProfiler::pop()
|
||||
#define TIMER_POP_PUSH(x) ServerProfiler::popPush(x)
|
||||
// #define TIMER_PUSH(x) ServerProfiler::push(x)
|
||||
// #define TIMER_POP() ServerProfiler::pop()
|
||||
// #define TIMER_POP_PUSH(x) ServerProfiler::popPush(x)
|
||||
#else
|
||||
#define TIMER_PUSH(x) ((void*)0)
|
||||
#define TIMER_POP() ((void*)0)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "ServerProfiler.h"
|
||||
// #include "ServerProfiler.h"
|
||||
|
||||
std::stack<ServerProfiler::Entry> ServerProfiler::stack;
|
||||
std::unordered_map<std::string, double> ServerProfiler::times;
|
||||
// std::stack<ServerProfiler::Entry> ServerProfiler::stack;
|
||||
// std::unordered_map<std::string, double> ServerProfiler::times;
|
||||
|
||||
@@ -1,43 +1,43 @@
|
||||
#pragma once
|
||||
// #pragma once
|
||||
|
||||
#include <chrono>
|
||||
#include <ratio>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <stack>
|
||||
// #include <chrono>
|
||||
// #include <ratio>
|
||||
// #include <iostream>
|
||||
// #include <string>
|
||||
// #include <unordered_map>
|
||||
// #include <stack>
|
||||
|
||||
namespace ServerProfiler {
|
||||
using clock = std::chrono::high_resolution_clock;
|
||||
// namespace ServerProfiler {
|
||||
// using clock = std::chrono::high_resolution_clock;
|
||||
|
||||
struct Entry {
|
||||
std::string name;
|
||||
clock::time_point start;
|
||||
};
|
||||
// struct Entry {
|
||||
// std::string name;
|
||||
// clock::time_point start;
|
||||
// };
|
||||
|
||||
static std::stack<Entry> stack;
|
||||
static std::unordered_map<std::string, double> times;
|
||||
// static std::stack<Entry> stack;
|
||||
// static std::unordered_map<std::string, double> times;
|
||||
|
||||
inline void push(const std::string& name) {
|
||||
stack.push({name, clock::now()});
|
||||
}
|
||||
// inline void push(const std::string& name) {
|
||||
// stack.push({name, clock::now()});
|
||||
// }
|
||||
|
||||
inline void pop() {
|
||||
auto end = clock::now();
|
||||
auto e = stack.top();
|
||||
stack.pop();
|
||||
// inline void pop() {
|
||||
// auto end = clock::now();
|
||||
// auto e = stack.top();
|
||||
// stack.pop();
|
||||
|
||||
double dt = std::chrono::duration<double, std::micro>(end - e.start).count();
|
||||
times[e.name] += dt;
|
||||
}
|
||||
// double dt = std::chrono::duration<double, std::micro>(end - e.start).count();
|
||||
// times[e.name] += dt;
|
||||
// }
|
||||
|
||||
inline void popPush(const std::string& name) {
|
||||
pop(); push(name);
|
||||
}
|
||||
// inline void popPush(const std::string& name) {
|
||||
// pop(); push(name);
|
||||
// }
|
||||
|
||||
inline void report() {
|
||||
for (auto& it : times) {
|
||||
std::cout << "[PROFILER] " << it.first << ": " << it.second << std::endl;
|
||||
}
|
||||
}
|
||||
};
|
||||
// inline void report() {
|
||||
// for (auto& it : times) {
|
||||
// std::cout << "[PROFILER] " << it.first << ": " << it.second << std::endl;
|
||||
// }
|
||||
// }
|
||||
// };
|
||||
Reference in New Issue
Block a user