{"id":15370216,"url":"https://github.com/jedisct1/rust-coarsetime","last_synced_at":"2025-04-08T04:13:52.950Z","repository":{"id":13076646,"uuid":"73506509","full_name":"jedisct1/rust-coarsetime","owner":"jedisct1","description":"Time and duration crate optimized for speed and API stability.","archived":false,"fork":false,"pushed_at":"2025-03-17T04:47:35.000Z","size":111,"stargazers_count":68,"open_issues_count":1,"forks_count":18,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-01T03:33:30.686Z","etag":null,"topics":["crates","rust","time","timestamps"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jedisct1.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-11-11T19:46:19.000Z","updated_at":"2025-03-03T20:43:19.000Z","dependencies_parsed_at":"2024-12-21T17:04:51.327Z","dependency_job_id":"52f95ae4-4f85-4924-9556-6b9c84c74808","html_url":"https://github.com/jedisct1/rust-coarsetime","commit_stats":{"total_commits":135,"total_committers":11,"mean_commits":"12.272727272727273","dds":"0.14074074074074072","last_synced_commit":"5cd909b7b63aaad198c4465bb387d16893c49f5b"},"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jedisct1%2Frust-coarsetime","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jedisct1%2Frust-coarsetime/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jedisct1%2Frust-coarsetime/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jedisct1%2Frust-coarsetime/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jedisct1","download_url":"https://codeload.github.com/jedisct1/rust-coarsetime/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247773719,"owners_count":20993639,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["crates","rust","time","timestamps"],"created_at":"2024-10-01T13:40:24.870Z","updated_at":"2025-04-08T04:13:52.929Z","avatar_url":"https://github.com/jedisct1.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Documentation](https://docs.rs/coarsetime/badge.svg)](https://docs.rs/coarsetime)\n[![Windows build status](https://ci.appveyor.com/api/projects/status/xlbhk9850dvl5ylh?svg=true)](https://ci.appveyor.com/project/jedisct1/rust-coarsetime)\n# coarsetime\n\nA Rust crate to make time measurements, that focuses on speed, API stability and portability.\n\nThis crate is a partial replacement for the `Time` and `Duration` structures\nfrom the standard library, with the following differences:\n\n* Speed is privileged over accuracy. In particular, `CLOCK_MONOTONIC_COARSE` is\nused to retrieve the clock value on Linux systems, and transformations avoid\noperations that can be slow on non-Intel systems.\n* The number of system calls can be kept to a minimum. The \"most recent\ntimestamp\" is always kept in memory. It can be read with just a load operation,\nand can be updated only as frequently as necessary.\n* The API is stable, and the same for all platforms. Unlike the standard library, it doesn't silently compile functions that do nothing but panic at runtime on some platforms.\n\n# Installation\n\n`coarsetime` is available on [crates.io](https://crates.io/crates/coarsetime)\nand works on Rust stable, beta, and nightly.\n\nWindows and Unix-like systems are supported.\n\nAvailable feature:\n\n* `wasi-abi2`: when targeting WASI, use the second preview of the ABI. Default is to use the regular WASI-core ABI.\n\n# Documentation\n\n[API documentation](https://docs.rs/coarsetime)\n\n# Example\n\n```rust\nextern crate coarsetime;\n\nuse coarsetime::{Duration, Instant, Updater};\n\n// Get the current instant. This may require a system call, but it may also\n// be faster than the stdlib equivalent.\nlet now = Instant::now();\n\n// Get the latest known instant. This operation is super fast.\n// In this case, the value will be identical to `now`, because we haven't\n// updated the latest known instant yet.\nlet ts1 = Instant::recent();\n\n// Update the latest known instant. This may require a system call.\n// Note that a call to `Instant::now()` also updates the stored instant.\nInstant::update();\n\n// Now, we may get a different instant. This call is also super fast.\nlet ts2 = Instant::recent();\n\n// Compute the time elapsed between ts2 and ts1.\nlet elapsed_ts2_ts1 = ts2.duration_since(ts1);\n\n// Operations such as `+` and `-` between `Instant` and `Duration` are also\n// available.\nlet elapsed_ts2_ts1 = ts2 - ts1;\n\n// Returns the time elapsed since ts1.\n// This retrieves the actual current time, and may require a system call.\nlet elapsed_since_ts1 = ts1.elapsed();\n\n// Returns the approximate time elapsed since ts1.\n// This uses the latest known instant, and is super fast.\nlet elapsed_since_recent = ts1.elapsed_since_recent();\n\n// Instant::update() should be called periodically, for example using an\n// event loop. Alternatively, the crate provides an easy way to spawn a\n// background task that will periodically update the latest known instant.\n// Here, the update will happen every 250ms.\nlet updater = Updater::new(250).start().unwrap();\n\n// From now on, Instant::recent() will always return an approximation of the\n// current instant.\nlet ts3 = Instant::recent();\n\n// Stop the task.\nupdater.stop().unwrap();\n\n// Returns the elapsed time since the UNIX epoch\nlet unix_timestamp = Clock::now_since_epoch();\n\n// Returns an approximation of the elapsed time since the UNIX epoch, based on\n// the latest time update\nlet unix_timestamp_approx = Clock::recent_since_epoch();\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjedisct1%2Frust-coarsetime","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjedisct1%2Frust-coarsetime","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjedisct1%2Frust-coarsetime/lists"}