//
|
// Created by Scheaven on 2020/5/14.
|
//
|
|
#ifndef DEMO_TIME_UTIL_H
|
#define DEMO_TIME_UTIL_H
|
|
#include <sys/time.h>
|
#include <cstdio>
|
#include <time.h>
|
#include <stdlib.h>
|
#include <string>
|
#include <algorithm>
|
#include <sstream>
|
|
int get_run_time(struct timeval *result, struct timeval *begin, struct timeval *end);
|
|
time_t strTime2unix(char* timeStamp);
|
|
long char_2_unix(char* str1);
|
|
char* fa_getSysTime();
|
|
std::string random_int(size_t length);
|
|
#include <chrono>
|
#include "log_util.h"
|
#include <boost/format.hpp>
|
|
class Timer
|
{
|
public:
|
static Timer* instance;
|
static Timer* getInstance();
|
|
Timer();
|
public:
|
void reset();
|
double elapsed() const;
|
void out(std::string message="");
|
// DEBUG((boost::format("nhao%d")%1).str());
|
double get_duration() const;
|
private:
|
using clock_ = std::chrono::high_resolution_clock;
|
using second_=std::chrono::duration<double,std::milli>;
|
std::chrono::time_point<clock_>beg_;
|
};
|
|
#endif //DEMO_TIME_UTIL_H
|