Commit Graph

3 Commits

Author SHA1 Message Date
Ewout van Bekkum
830d5d1ac0 pw_chrono: Improve SystemClock C API
Changes the SystemClock C Api to:
1) Use a pw_chrono_SystemClock_Duration struct instead of aliasing
   an int64_t under pw_chrono_SystemClock_TickCount which could
   accidentally permit direct tick usage.
2) Add PW_SYSTEM_CLOCK_{MS,S,MIN,H} and
   PW_SYSTEM_CLOCK_{MS,S,MIN,H}_CEIL to permit C API users to
   create durations which round up to the nearest tick for deadlines
   and timeouts, mirroring std::chrono::ceil.
3) Add PW_SYSTEM_CLOCK_{MS,S,MIN,H}_FLOOR to permit C API users to
   create durations which round down to the nearest tick for oddball
   corner cases, mirroring std::chrono::floor.
4) In order to enable said macros, the system_clock_config.h backend
   config was changed to require the clock period as a preprocessor
   defines instead of a std::ratio<>.
5) Renames pw_chrono_SystemClock_TimeDelta to
   pw_chrono_SystemClock_TimeElapsed to make the argument ordering
   make more sense.
6) Changes existing std::chrono::duration_cast usage to
   std::chrono::ceil and std::chrono:floor to set a good example
   to be explicit on rounding.
7) Renames pw_chrono_SystemClock_TickCountsToNsTruncate accordingly to
   pw_chrono_SystemClock_DurationToNsFloor.

Requires: pigweed-internal:9340
Change-Id: Ia628dceac53f964eda7c4aacd3d790b8b0e92207
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/31280
Commit-Queue: Ewout van Bekkum <ewout@google.com>
Reviewed-by: Wyatt Hepler <hepler@google.com>
2021-01-30 01:48:08 +00:00
Ewout van Bekkum
1502a40b68 pw_trace_tokenized: use steady_clock, not system_clock
Updates the pw_trace_tokenized's host_trace_time backend to use
the std::chrono::steady_clock which is monotonic, instead of the
std::chrono::system_clock which may unexpectedly jump backwards
causing odd trace artifacts.

Change-Id: I42749e7a8272650c23f2ff420615a23191df3b1a
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/23222
Reviewed-by: Rob Oliver <rgoliver@google.com>
Reviewed-by: Keir Mierle <keir@google.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
Pigweed-Auto-Submit: Ewout van Bekkum <ewout@google.com>
2020-11-03 16:21:43 +00:00
Robert Oliver
6d05de13e7 pw_trace: tokenizer basic example
Run the trace sample app and dump all trace data to a file.
- Use std::chrono::system_clock as the time source for host builds.
- Add trace_to_file.h which registers callbacks and saves all trace data
to a provided binary file.

Change-Id: I57fac75ed91fc98646e7aae920897687a39549ab
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/13802
Commit-Queue: Rob Oliver <rgoliver@google.com>
Reviewed-by: (☞゚∀゚)☞ Tennessee Carmel-Veilleux  <tennessee@google.com>
2020-07-31 20:57:23 +00:00