派生自 Algorithm/baseDetector

孙天宇
2022-07-12 ce9d187fd294cca192a27f52719094e9df7b1b62
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//
// 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