Buckets:

soixantesept's picture
download
raw
1.2 kB
#pragma once
#include <cassert>
#include <chrono>
#include <cinttypes>
#include <cstdint>
#include <cstdio>
/**
* Track time and memory used.
* @remark: only @ref Array<T> reports its memory usage, we don't know about other types
*/
class ProgramChecker {
private:
uint64_t memUsed {}; /**< Bytes currently in use (all allocated minus all freed) */
uint64_t maxMem {}; /**< Most bytes allocated ever */
std::chrono::time_point<std::chrono::high_resolution_clock> startTime;
/**
* Constructor is private so that it cannot be called
*/
ProgramChecker() {
startTime = std::chrono::high_resolution_clock::now();
}
/**
* Copy constructor is private so that it cannot be called
*/
ProgramChecker(ProgramChecker const & /*unused*/) {}
/**
* Assignment operator is private so that it cannot be called
*/
ProgramChecker& operator=(ProgramChecker const & /*unused*/) { return *this; }
static ProgramChecker *instance;
public:
static ProgramChecker* getInstance();
void alloc(uint64_t n);
void free(uint64_t n);
double getRuntime() const;
/**
* Print elapsed time and used memory
*/
void print() const;
~ProgramChecker();
};

Xet Storage Details

Size:
1.2 kB
·
Xet hash:
950c666b2bc9a7f611c58ef1c9589d737fa22389b436b28e3a4f04b54fd413de

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