https://github.com/misyltoad/ephemeral
A high-resolution cross-platform time library in C that supports sleeping and "clocks" that can be used to tell you if a certain time has passed since its start.
https://github.com/misyltoad/ephemeral
Last synced: 15 days ago
JSON representation
A high-resolution cross-platform time library in C that supports sleeping and "clocks" that can be used to tell you if a certain time has passed since its start.
- Host: GitHub
- URL: https://github.com/misyltoad/ephemeral
- Owner: misyltoad
- License: mit
- Created: 2016-08-29T18:13:54.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2016-09-22T17:58:36.000Z (over 9 years ago)
- Last Synced: 2025-01-13T04:44:50.014Z (over 1 year ago)
- Language: C
- Size: 835 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Ephemeral
## A simple time library in C.
### Features
* Getting high-resolution time.
* Sleeping the current thread.
* "Clocks" that can be used to see if a specific time has passed since their start or given value.
* Tick counter with embedded clock.
* Ease-of-use: Full documentation of every struct and function with Doxygen!
* A nice licence. (MIT)
* Debug overflow checking.
* Speed.
### Instructions
#### Preparation
You may use the premake build system to generate a .sln file for your version of Visual Studio.
To compile in your own project so that you do not have to link, all you need to add the UnityBuild.c and it will sort out all of the platform specific stuff, that is all.
If you would like to initialise Ephemeral yourself, define EPHEMERAL_DISABLE_INITIALISERS and call Ephemeral_Init(). Calling Ephemeral_Init without EPHEMERAL_DISABLE_INITIALISERS is ***NOT*** required, but it shouldn't cause any issues.
You may disable assertions in by building in Release or defining EPHEMERAL_DISABLE_ASSERTS.
#### Using
Ephemeral can be utilized in many different ways.
One example would be to use it in a game engine for getting delta-time:
```c
...
Ephemeral_TickCounter tc = Ephemeral_TickCounterCreate();
Ephemeral_Time prevTime = Ephemeral_TimeNow();
// Sleep for 0.5s
Ephemeral_TimeSleep(Ephemeral_TimeFromMicroseconds(500));
for(;;)
{
Ephemeral_Time currentTime = Ephemeral_TimeNow();
Ephemeral_Time deltaTime = Ephemeral_TimeMinus(currentTime, prevTime);
prevTime = currentTime;
...
if (Ephemeral_TickCounterUpdate(&tc, Ephemeral_TimeFromMilliseconds(500)))
{
// This would update every 500ms (0.5s).
printf("Your FPS is: %f", tc.tickRate);
// You could use it to get frame time also.
printf("Your frame time is: %f", 1000.0f / (float)tc.tickRate);
}
...
}
...
```