chrono

Mingw, boost, and runtime “procedure entry point could not be located”

空扰寡人 提交于 2019-12-13 16:03:36
问题 Problem I'm making a simple server app with websocketpp on Windows using mingw. I got my code to compile and link successfully. However, when I start the app it gives me the following error window: The procedure entry point _ZNSt6chrono3_V212steady_clock3nowEv could not be located in the DLL D:\work\wild_web\a.exe My setup Here's how I compile and link my code: g++ -std=c++11 -march=i686 d:/work/wild_web/main.cpp -o a.exe -ID:/work/libs/boost_1_61_0 -ID:/work/websocketpp-master/websocketpp

using std::chrono::high_resolution_clock to write a frame 30 times per second

谁都会走 提交于 2019-12-13 12:09:54
问题 I'm using OpenCV to write a video file. For cv::VideoWriter to work correctly the call to the write() function has to happen exactly 30 times per second (for a 30fps video). I found this code which uses the boost library to achieve this. I want to to the same but using std::chrono in my program. This is my implementation: std::chrono::high_resolution_clock::time_point prev = std::chrono::high_resolution_clock::now(); std::chrono::high_resolution_clock::time_point current = prev; long long

Function to return a chrono::duration using templates for the time unit

穿精又带淫゛_ 提交于 2019-12-13 03:38:55
问题 I'm new to C++ templates and I'm trying to write a function which returns a chrono::duration with the specified time unit and type. For instance, this line gives me the time difference in seconds as double: std::chrono::duration<double> secd = std::chrono::duration_cast<std::chrono::duration<double,std::ratio<1>>>(end - start); I have a class function which gives me a time duration, and I would like to use templates to indicate the type and unit for the return value (in the previous example,

Creating a `std::chrono::time_point` from a calendar date known at compile time

你。 提交于 2019-12-12 12:09:56
问题 This answer shows how to parse a string to a std::chrono::time_point , as follows: std::tm tm = {}; std::stringstream ss("Jan 9 2014 12:35:34"); ss >> std::get_time(&tm, "%b %d %Y %H:%M:%S"); auto tp = std::chrono::system_clock::from_time_t(std::mktime(&tm)); If I want to create a std::chrono::time_point from a (Gregorian) calendar date whose year, month, and day-of-month are known at compile time, is there any simpler way than parsing it from a string as suggested above? 回答1: Yes, you can do

Time measurements with High_resolution_clock not working as intended

蓝咒 提交于 2019-12-12 03:18:41
问题 I want to be able to measure time elapsed (for frame time) with my Clock class. (Problem described below the code.) Clock.h typedef std::chrono::high_resolution_clock::time_point timePt; class Clock { timePt currentTime; timePt lastTime; public: Clock(); void update(); uint64_t deltaTime(); }; Clock.cpp #include "Clock.h" using namespace std::chrono; Clock::Clock() { currentTime = high_resolution_clock::now(); lastTime = currentTime; } void Clock::update() { lastTime = currentTime;

getting chrono time in specific way

前提是你 提交于 2019-12-11 22:44:58
问题 I have following C code: uint64_t combine(uint32_t const sec, uint32_t const usec){ return (uint64_t) sec << 32 | usec; }; uint64_t now3(){ struct timeval tv; gettimeofday(&tv, NULL); return combine((uint32_t) tv.tv_sec, (uint32_t) tv.tv_usec); } What this do it combine 32 bit timestamp, and 32 bit "something", probably micro/nanoseconds into single 64 bit integer. I have really hard time to rewrite it with C++11 chrono. This is what I did so far, but I think this is wrong way to do it. auto

Get time stamp via Boost.Chrono in resolution of nanoseconds

£可爱£侵袭症+ 提交于 2019-12-11 15:41:31
问题 Does boost chrono provides time stamp with nanoseconds resolution?? If yes how to get the time stamp? 回答1: Nanoseconds resolution ? On which hardware do you want to run your program ? On my PC, my performance counter has a frequency of approx. 4 Mhz, so a tick last 250 ns. As answered here, boost chrono can give you the nanosecond resolution, but you will not be sure of the measure's accuracy. 回答2: In order to easily get time stamps with boost chrono for different measurements you can use

Convert double to struct tm

心不动则不痛 提交于 2019-12-11 10:36:08
问题 I have a double containing seconds. I would like to convert this into a struct tm . I can't find a standard function which accomplishes this. Do I have to fill out the struct tm by hand? I just accidentally asked this about converting to a time_t and http://www.StackOverflow.com will not let me post unless I link it. 回答1: Well, you accidentally asked the right question before. Convert double to time_t , and then convert that to a struct tm . There's no subsecond field in struct tm anyway. 回答2

Is it possible to use std::chrono::duration with Rep type as double? I get compiler error in vs2012 when I try

一个人想着一个人 提交于 2019-12-11 08:09:18
问题 I get a following compiler (vs2012) error: Error 3 error C2679: binary '+=' : no operator found which takes a right-hand operand of type 'const std::chrono::duration<_Rep,_Period>' (or there is no acceptable conversion) c:\program files (x86)\microsoft visual studio 11.0\vc\include\chrono 749 My definition of duration is: // Tick interval type in nanoseconds typedef std::chrono::duration<double, std::ratio<1, 100000000>> tick_interval_type; Same error when I use float... It only compiles when

chrono with different time periods?

[亡魂溺海] 提交于 2019-12-11 04:56:40
问题 Currently I am using boost::rational<std::uint64> to keep track in my application. Basically I have a clock that runs over a very long period of time and will be tick by different components of different time resolutions, e.g. 1/50s, 1/30s, 1001/30000s etc... I want to maintain perfect precision, i.e. no floating point. boost::rational works well for this purpose, however I think it would be better design to use std::chrono::duration for this. My problem though is, how can I use std::chrono: