edith_codecs
Clone
https://git.tahinli.com/Tahinli/edith_codecs.git
0 watching0 forksRust370.3 MiB9b67700Tahinli3 days ago4021 commits
| 1 | //! Opt-in timing of the decoder's threads, for finding where they sit idle. |
| 2 | //! |
| 3 | //! `EC_H265_TRACE=1` turns it on. Off (the default), every hook is one check of a cached |
| 4 | //! flag and no clock is read. On, each thread adds the time it spends in each [`Phase`] to |
| 5 | //! its own totals. A thread's totals are merged into the table of its role when the thread |
| 6 | //! ends (or, for the calling thread, when [`report`] runs), and [`report`] prints the table |
| 7 | //! to stderr at the end of the stream. |
| 8 | |
| 9 | use RefCell; |
| 10 | use BTreeMap; |
| 11 | use ; |
| 12 | use ; |
| 13 | |
| 14 | /// The phases a thread's time is split into. |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 | |
| 22 | |
| 23 | |
| 24 | |
| 25 | |
| 26 | |
| 27 | |
| 28 | |
| 29 | |
| 30 | |
| 31 | |
| 32 | |
| 33 | |
| 34 | |
| 35 | |
| 36 | |
| 37 | const N: usize = 8; |
| 38 | /// Whether tracing is on (`EC_H265_TRACE` set to anything but `0`). |
| 39 | |
| 40 | |
| 41 | |
| 42 | |
| 43 | |
| 44 | /// The start of a timed span, or `None` when tracing is off (no clock is read). |
| 45 | |
| 46 | |
| 47 | |
| 48 | |
| 49 | |
| 50 | /// Add the time since `start` to `phase` of this thread. |
| 51 | |
| 52 | |
| 53 | |
| 54 | |
| 55 | |
| 56 | |
| 57 | |
| 58 | |
| 59 | |
| 60 | |
| 61 | |
| 62 | |
| 63 | |
| 64 | /// Name this thread's role in the report (the default is `caller`). |
| 65 | |
| 66 | |
| 67 | |
| 68 | |
| 69 | |
| 70 | |
| 71 | |
| 72 | |
| 73 | |
| 74 | |
| 75 | |
| 76 | |
| 77 | |
| 78 | |
| 79 | |
| 80 | |
| 81 | |
| 82 | |
| 83 | |
| 84 | |
| 85 | |
| 86 | |
| 87 | |
| 88 | |
| 89 | |
| 90 | |
| 91 | |
| 92 | |
| 93 | |
| 94 | |
| 95 | |
| 96 | |
| 97 | |
| 98 | |
| 99 | |
| 100 | |
| 101 | |
| 102 | |
| 103 | |
| 104 | |
| 105 | |
| 106 | |
| 107 | |
| 108 | |
| 109 | thread_local! |
| 110 | |
| 111 | |
| 112 | |
| 113 | /// Merge the calling thread's totals, then print every role's table to stderr and clear |
| 114 | /// the tables. Worker threads have merged already: they are joined before this runs. |
| 115 | |
| 116 | |
| 117 | |
| 118 | |
| 119 | |
| 120 | |
| 121 | |
| 122 | |
| 123 | |
| 124 | |
| 125 | |
| 126 | |
| 127 | |
| 128 | |
| 129 | |
| 130 | |
| 131 | |
| 132 | |
| 133 | |
| 134 | |
| 135 | |
| 136 | |
| 137 | |
| 138 | |
| 139 | |
| 140 | |
| 141 | |
| 142 | |
| 143 | |
| 144 | |
| 145 | |
| 146 | |
| 147 | |
| 148 | |
| 149 | |
| 150 | |
| 151 | |
| 152 | |
| 153 | |
| 154 | |
| 155 |