1# //base: Time-Related Functionality 2 3This directory contains the portions of //base that deal with time-related 4concepts. Most critical are the classes in [time.h](time.h). 5 - `Time` represents a specific wall-clock time. It is computed from the system 6clock, meaning successive requests for the current time might not always 7monotonically increase (e.g. across automatic or manual clock adjustments). 8Generally it is appropriate for anything human-visible, e.g. the last modified 9date/time of a file or a future time when Chrome will be automatically 10restarted, but users must safely handle negative durations and other effects of 11the non-monotonic clock. 12 - `TimeTicks` is computed from an incrementing counter. It thus increases 13monotonically, meaning it's usually appropriate for determining how much time 14elapses between two nearby events, e.g. for function timing for profiling, or to 15schedule a task "100 milliseconds from now", regardless of what the clock reads 16at that point. However, its behavior across power-saving mode changes is 17platform-dependent, meaning it may not increment during times when the system 18clock continues to run, and the precise conditions under which it does increment 19vary by platform. This usually makes it inappropriate for long durations, 20especially in cross-platform code; for example, a histogram that uses 21`TimeTicks` to count events in a thirty-day window will show very different 22results on a platform that pauses the counter during sleep compared to one where 23it continues to run. It is also non-sensical to try and convert a `TimeTicks` to 24a `Time` and then use that as a reference point for any other `TimeTicks` value, 25since even within the same process, both intervening sleeps and intervening 26clock adjustments may mean the values should have had different reference points. 27 - `TimeDelta` represents a duration between two Times or TimeTicks. 28 29There are also various files dealing with clocks, which are primarily useful 30when tests need to modify how the program tracks the passage of time. See 31[/base/test/task_environment.h](/base/test/task_environment.h)'s `MOCK_TIME` 32ability for 33[testing components which post tasks](/docs/threading_and_tasks_testing.md). 34