Buckets:

soixantesept's picture
download
raw
981 Bytes
#include "ProgramChecker.hpp"
ProgramChecker *ProgramChecker::instance = nullptr;
ProgramChecker* ProgramChecker::getInstance() {
if( instance == nullptr ) {
instance = new ProgramChecker();
}
return instance;
}
void ProgramChecker::alloc(uint64_t n) {
memUsed += n;
if( memUsed > maxMem ) {
maxMem = memUsed;
}
}
void ProgramChecker::free(uint64_t n) {
assert(memUsed >= n);
memUsed -= n;
}
double ProgramChecker::getRuntime() const {
const std::chrono::time_point<std::chrono::high_resolution_clock> finishTime = std::chrono::high_resolution_clock::now();
return std::chrono::duration<double>(finishTime - startTime).count();
}
void ProgramChecker::print() const {
const double runtime = getRuntime();
printf("Time %1.2f sec, used %" PRIu64 " MB (%" PRIu64 " bytes) of memory\n", runtime, maxMem >> 20, maxMem);
}
ProgramChecker::~ProgramChecker() {
assert(memUsed == 0); // We expect that all reserved memory is already properly freed
}

Xet Storage Details

Size:
981 Bytes
·
Xet hash:
43ad6fc0b4058d034165d9e38e7f563c395ee2ae441d67c300500265cef2f997

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.