Once we have the two components, we can create our timespec value. We subtract this count from the total duration to get the remaining nanosecond count. First we capture the portion of the duration which can be represented by a round number of seconds. Thank you for the work on TIC-80! It's a really great project, and I'd love to see it become better. Converting from std::chrono::duration to timespec is a two step process. I can always use an older build, I guess, but this locks me to an outdated version of Fennel language which is not good either. Not using delta time at all to compensate for framerate changes is an option, but a rather poor one. Users are also locked to using the web version of games because the desktop build is 10 times slower due to this bug. Which is not the best way to do it, as the sound is lagging, and overall performance is usually better in the desktop build. This seems like a pretty serious bug, basically making development only possible in a web version. I've tried to see if I'll be able to at least revert the parts of the code, to use an older method, but I'm lacking a lot of knowledge about the codebase, and reverting seemed to be not as easy to do, as there were a lot of changes in the overall code related to time AFAICT. Sorry to bother, but are there any plans on fixing this? The ticket is in the hotfix 1.0 board since May 8 The question is how do you want to pass a duration into a function that expects a timepoint (e.g. use one that already exists and is proven to work? Why make our own timeMs function that uses a library's timekeeping when we can just. hands you a value in seconds, and other systems want you to use a consistent calculation to turn a timespec struct into a nanosecond value that you can turn into milliseconds or whatever you need). Instead you should stick with rich types, such as std::chrono. In general you should avoid using weak types like float or long long to represent a duration. count () will return a long long equal to the number of milliseconds represented by the duration. But I have no idea what is a resolution of obtained in this way timepoint, and I dont know how to get this time as a simple unsigned long long, and I havent any conception how to cast it to another resolution. The main reason I suggested using Sokol's timer functions regardless of platform is that it would provide a consistent API to something that is not quite consistent between platforms (i.e Windows expects you to do math with a QuadPart member on the object, Mac wants you to convert using a timebase, Emscripten just. So if the durations representation is long long, and the period is std::milli, then. Drawing frame at 0 s Drawing frame at 134.499 s Drawing frame at 274.337 s Drawing frame at 416.571 s Drawing frame at 561. which is just an abstraction over the same stuff Sokol's timer lib uses, since the right way to get time is the right way to get time is the right way to get time. ie, if someone was compiling against SDL they'd get if they were compiling against Sokol they'd get the stm_now/stm_ms, etc.Īctually, prior SDL builds seem to have used SDL_GetPerformanceCounter. This library makes it very easy to extract a year/month/day from std::systemclock::timepoint, and even hours:minutes:seconds:fractional-seconds. You can see the note on this page : 'User code should usually use std::chrono::clockcast, which provides a generic interface to convert time points between clocks, rather than call these functions directly.' kingsjester. For other clocks thers the static function totimet, but on GCC (MinGW 4.8.0) this function is not present. For debug purpose is usefull to have the calendar (or something similar). and then abstract that behind a single generic timeMs function we own. Im using the steadyclock for saving the time stamp of some messages. How long that tick is is dependent on the highresolutionclock of your Standard Library implementation, similarly, the epoch is also defined by your Standard Library implementation. The timespec type can be used to store either a time interval or absolute time.We should probably consider using the timekeeping mechanics of the library that has been requested at build time. SeanLynch It is the count of ticks of the clock since the epoch of that clock (between the time point and the epoch). Below are a few utility functions that I came up with to handle common conversions.Īs a quick refresher, timespec is a type defined in the ctime header (aka time.h). I primarily work with std::chrono types in C++ and was surprised that there were no (obvious) existing conversion methods. I was working with some POSIX APIs recently and needed to supply a timespec value.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |