frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

Time in C++: Inter-Clock Conversions, Epochs, and Durations

https://www.sandordargo.com/blog/2025/12/24/clocks-part-5-conversions
21•ibobev•2d ago

Comments

barishnamazov•1h ago
I built a local competitive programming judge a while back where I fell into the exact trap of manually correlating steady_clock and system_clock.

I was timestamping everything using steady_clock to strictly enforce the time limits, and then just applied a calculated offset to convert that to wall time for the "Submission Date" display. It worked in testing, but during a long stress-test session, my laptop did an NTP sync. The logs then showed submissions appearing to happen before the source code file was last modified, which confused the caching logic. I was essentially betting that system_clock was stable relative to steady_clock over the process lifetime.

I eventually refactored to exactly what the article suggests: use steady_clock strictly for the runtime enforcement (is duration < 2.0s?), but capture system_clock::now() explicitly at the submission boundary for the logs, rather than trying to do math on the steady timestamp.

Also, +1 for std::chrono::round in C++20. I’ve seen code where duration_cast was used to "round" execution times to milliseconds for display, but it was silently flooring them. In a competitive programming context, reporting 1000ms when the actual time was 1000.9ms is a misleading difference because the latter gets Time Limit Exceeded error. Explicit rounding makes the intent much clearer.

loeg•48m ago
The thing I ran into most recently is that std::chrono (weirdly?) only supports clocks with compile-time fixed fractional conversion to reference time (~seconds). E.g., you can't implement a std::chrono clock where the count() unit is the native CPU's cycle counter, which will have some runtime-determined conversion to seconds. The types make it impossible.
cyberax•30m ago
C++ chrono is weird. It's both over-abstracted and yet has some thoughtless features that just negate this over-abstraction.

I remember not being able to represent the time in fractional units, like tertias (1/60-th of a second) but that was mostly an academic problem. More importantly, it was not possible to express duration as a compound object. I wanted to be able to represent the dates with nanosecond precision, but with more than 250 years of range. I think it is still not possible?

What an unprocessed photo looks like

https://maurycyz.com/misc/raw_photo/
402•zdw•2h ago•99 comments

Stepping down as Mockito maintainer after 10 years

https://github.com/mockito/mockito/issues/3777
199•saikatsg•5h ago•90 comments

Unity's Mono problem: Why your C# code runs slower than it should

https://marekfiser.com/blog/mono-vs-dot-net-in-unity/
89•iliketrains•3h ago•45 comments

62 years in the making: NYC's newest water tunnel nears the finish line

https://ny1.com/nyc/all-boroughs/news/2025/11/09/water--dep--tunnels-
45•eatonphil•2h ago•13 comments

Rich Hickey: Thanks AI

https://gist.github.com/richhickey/ea94e3741ff0a4e3af55b9fe6287887f
64•austinbirch•1h ago•8 comments

Spherical Cow

https://lib.rs/crates/spherical-cow
28•Natfan•2h ago•1 comments

MongoBleed Explained Simply

https://bigdata.2minutestreaming.com/p/mongobleed-explained-simply
80•todsacerdoti•4h ago•21 comments

PySDR: A Guide to SDR and DSP Using Python

https://pysdr.org/content/intro.html
100•kklisura•5h ago•6 comments

Show HN: My app just won best iOS Japanese learning tool of 2025 award

https://skerritt.blog/best-japanese-learning-tools-2025-award-show/
35•wahnfrieden•1h ago•3 comments

Researchers Discover Molecular Difference in Autistic Brains

https://medicine.yale.edu/news-article/molecular-difference-in-autistic-brains/
36•amichail•3h ago•12 comments

Growing up in “404 Not Found”: China's nuclear city in the Gobi Desert

https://substack.com/inbox/post/182743659
683•Vincent_Yan404•18h ago•296 comments

Slaughtering Competition Problems with Quantifier Elimination

https://grossack.site/2021/12/22/qe-competition.html
16•todsacerdoti•2h ago•0 comments

Why I Disappeared – My week with minimal internet in a remote island chain

https://www.kenklippenstein.com/p/why-i-disappeared
31•eh_why_not•3h ago•3 comments

Time in C++: Inter-Clock Conversions, Epochs, and Durations

https://www.sandordargo.com/blog/2025/12/24/clocks-part-5-conversions
21•ibobev•2d ago•3 comments

Remembering Lou Gerstner

https://newsroom.ibm.com/2025-12-28-Remembering-Lou-Gerstner
65•thm•6h ago•29 comments

Building a macOS app to know when my Mac is thermal throttling

https://stanislas.blog/2025/12/macos-thermal-throttling-app/
227•angristan•13h ago•99 comments

Writing non-English languages with a QWERTY keyboard

https://altgr-weur.eu/altgr-intl.html
7•tokai•4d ago•0 comments

Dolphin Progress Report: Release 2512

https://dolphin-emu.org/blog/2025/12/22/dolphin-progress-report-release-2512/
74•akyuu•3h ago•5 comments

Fast Cvvdp Implementation in C

https://github.com/halidecx/fcvvdp
4•todsacerdoti•1h ago•0 comments

Doublespeak: In-Context Representation Hijacking

https://mentaleap.ai/doublespeak/
45•surprisetalk•6d ago•5 comments

How to Complain

https://outerproduct.net/trivial/2024-03-25_complain.html
10•ysangkok•2h ago•1 comments

Learn computer graphics from scratch and for free

https://www.scratchapixel.com
172•theusus•14h ago•24 comments

As AI gobbles up chips, prices for devices may rise

https://www.npr.org/2025/12/28/nx-s1-5656190/ai-chips-memory-prices-ram
45•geox•2h ago•29 comments

Intermission: Battle Pulses

https://acoup.blog/2025/12/18/intermission-battle-pulses/
6•Khaine•2d ago•0 comments

Software engineers should be a little bit cynical

https://www.seangoedecke.com/a-little-bit-cynical/
111•zdw•3h ago•83 comments

Show HN: Pion SCTP with RACK is 70% faster with 30% less latency

https://pion.ly/blog/sctp-and-rack/
35•pch07•7h ago•5 comments

One year of keeping a tada list

https://www.ducktyped.org/p/one-year-of-keeping-a-tada-list
221•egonschiele•6d ago•64 comments

Oral History of Richard Greenblatt (2005) [pdf]

https://archive.computerhistory.org/resources/text/Oral_History/Greenblatt_Richard/greenblatt.ora...
10•0xpgm•3d ago•0 comments

John Malone and the Invention of Liquid-Based Engines

https://permalink.lanl.gov/object/tr?what=info:lanl-repo/lareport/LA-UR-93-1350-25
14•akshatjiwan•4d ago•2 comments

Show HN: Phantas – A browser-based binaural strobe engine (Web Audio API)

https://phantas.io
16•AphantaZach•4h ago•8 comments