4 tickcount -- Display the kernel tick count in human-readable format
6 This is public domain software
14 typedef __int64 int64_t;
15 typedef unsigned __int64 uint64_t;
17 #define TICKS_YEAR (TICKS_DAY * ((uint64_t)365))
18 #define TICKS_MONTH (TICKS_DAY * ((uint64_t)30))
19 #define TICKS_WEEK (TICKS_DAY * ((uint64_t)7))
20 #define TICKS_DAY (TICKS_HOUR * ((uint64_t)24))
21 #define TICKS_HOUR (TICKS_MINUTE * ((uint64_t)60))
22 #define TICKS_MINUTE (TICKS_SECOND * ((uint64_t)60))
23 #define TICKS_SECOND ((uint64_t)1000)
25 #define SLICES_COUNT (sizeof(ticks_per_slice) / sizeof(ticks_per_slice[0]))
27 uint64_t ticks_per_slice[] =
39 _TCHAR * slice_names_singular[] =
51 _TCHAR * slice_names_plural[] =
66 uint64_t prevsliceval,
67 _TCHAR * prevsliceunit,
71 uint64_t tick_cur = tickcount / ticks_per_slice[curslice];
72 uint64_t tick_residual = tickcount % ticks_per_slice[curslice];
74 assert(tick_cur <= (~((uint64_t)0)));
76 if(tick_residual == 0)
78 /* the current slice is the last */
82 /* the current slice is the only */
87 (tick_cur == 1 ? slice_names_singular : slice_names_plural)[curslice]
92 /* the current slice is the last, and there's a previous slice */
93 assert(prevsliceunit);
95 /* print the previous and the current slice, and terminate */
99 (unsigned)prevsliceval,
103 (tick_cur == 1 ? slice_names_singular : slice_names_plural)[curslice]
107 else if(tick_cur != 0)
109 /* the current slice is not the last, and non-zero */
111 if(prevsliceval != 0)
113 /* there's a previous slice: print it */
114 assert(prevsliceunit);
115 _tprintf(_T("%u %s, "), (unsigned)prevsliceval, prevsliceunit);
118 /* recursion on the next slice size, storing the current slice */
123 (tick_cur == 1 ? slice_names_singular : slice_names_plural)[curslice],
130 the current slice is not the last, and zero: recursion, remembering the
131 previous non-zero slice
133 print_uptime(tick_residual, prevsliceval, prevsliceunit, curslice + 1);
139 print_uptime((uint64_t)GetTickCount(), 0, NULL, 0);
140 _puttc(_T('\n'), stdout);