@@ -370,6 +370,64 @@ by a scalar (numeric value)). Times can be written to/read from IO streams.
370
370
In the case of writing it is easy to choose the output unit, different
371
371
from the resolution unit.
372
372
373
+ Here are examples of common usage:
374
+
375
+ .. sourcecode :: cpp
376
+
377
+ Time t1 = MilliSeconds(1500); // 1.5 s = 1500 ms
378
+ Time t2 = MicroSeconds(500); // 500 microseconds
379
+ Time t3 = t1 + t2; // arithmetic
380
+ Time t4 = t3 * 2; // multiplication
381
+
382
+ if (t4 > Seconds(3))
383
+ {
384
+ std::cout << "t4 is greater than 3 seconds\n ";
385
+ }
386
+
387
+ double ms = t4.GetMilliSeconds(); // convert to double in ms
388
+
389
+ std::cout << t4.As(Time::MS) << "\n "; // stream with specific unit
390
+
391
+ .. note ::
392
+
393
+ When using floating-point values with constructors like ``Seconds(1.5) ``,
394
+ users should be aware that values smaller than the current resolution
395
+ will be rounded. For example, if the resolution is set to nanoseconds,
396
+ values like ``Seconds(1e-10) `` will be rounded to zero.
397
+ Consider inspecting ``Time::SetResolution() `` and using methods like
398
+ ``GetNanoSeconds() `` to understand how sub-resolution values behave in practice.
399
+
400
+ When calling ``Time::SetResolution() ``, there is a trade-off between
401
+ the precision of time measurements and the maximum simulation time
402
+ span that can be represented. Finer resolutions (like femtoseconds)
403
+ allow for more precise timing but reduce the maximum representable
404
+ duration.
405
+
406
+ .. list-table ::
407
+ :header-rows: 1
408
+ :widths: 25 25 50
409
+
410
+ * - Resolution Unit
411
+ - Smallest Step
412
+ - Approximate Max Time Span
413
+ * - Seconds
414
+ - 1 s
415
+ - ~2.9 × 10¹¹ years
416
+ * - Milliseconds
417
+ - 1 ms
418
+ - ~2.9 × 10⁸ years
419
+ * - Microseconds
420
+ - 1 µs
421
+ - ~2.9 × 10⁵ years
422
+ * - Nanoseconds
423
+ - 1 ns
424
+ - ~292 years
425
+ * - Picoseconds
426
+ - 1 ps
427
+ - ~107 days
428
+ * - Femtoseconds
429
+ - 1 fs
430
+ - ~2.6 hours
373
431
374
432
Scheduler
375
433
*********
0 commit comments