Fleet  0.0.9
Inference in the LOT
Functions
Timing.h File Reference
#include <chrono>
#include "Errors.h"
Include dependency graph for Timing.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

time_t convert_time (const std::string &s)
 Give a timepoint for the current time. More...
 

Function Documentation

◆ convert_time()

time_t convert_time ( const std::string &  s)

Give a timepoint for the current time.

Time is a goddamn nightmare, we are going to define our own time type
In Fleet, EVERYTHING is going to be stored as an unsigned long for ms
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
using time_ms = unsigned long;
using timept = std::chrono::high_resolution_clock::time_point;
timept now() {
return std::chrono::high_resolution_clock::now();
}
time_ms time_since(timept x) {
return std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now()-x).count();
}
// this is just handy for timing stuff -- put blocks of code between tic() and tic()
timept tic_start;
time_ms tic_elapsed;
void tic() {
tic_elapsed = time_since(tic_start);
tic_start = now();
}
double elapsed_seconds() {
return tic_elapsed / 1000.0;
}
std::string datestring() {
//https://stackoverflow.com/questions/40100507/how-do-i-get-the-current-date-in-c
time_t rawtime;
struct tm * timeinfo;
char buffer[80];
time (&rawtime);
timeinfo = localtime(&rawtime);
strftime(buffer,80,"%Y-%m-%d %I:%M:%S",timeinfo);
return std::string(buffer);
}
/*

Time conversions for fleet ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Converts our own time format to ms, which is what Fleet's time utilities use The time format we accept is #+(.#+)[smhd] where shmd specifies seconds, minutes, hours days

Parameters
s
Returns