| 251 | } |
| 252 | |
| 253 | void JKRThreadSwitch::draw(JKRThreadName_ *thread_name_list, JUTConsole *console) |
| 254 | { |
| 255 | const char *print_0 = " total: switch:%3d time:%d(%df)\n"; |
| 256 | const char *print_1 = " -------------------------------------\n"; |
| 257 | |
| 258 | if (!console) |
| 259 | { |
| 260 | /*#if DEBUG |
| 261 | OSReport(print_0, getTotalCount(), (int)_18, _10); |
| 262 | OSReport(print_1); |
| 263 | #endif*/ |
| 264 | } |
| 265 | else |
| 266 | { |
| 267 | console->clear(); |
| 268 | console->print_f(print_0, getTotalCount(), (int)_18, _10); |
| 269 | console->print(print_1); |
| 270 | } |
| 271 | |
| 272 | for (JSUListIterator<JKRThread> iterator = JKRThread::getList().getFirst(); iterator != JKRThread::getList().getEnd(); ++iterator) |
| 273 | { |
| 274 | JKRThread *thread = iterator.getObject(); |
| 275 | JKRThread::TLoad *loadInfo = thread->getLoadInfo(); |
| 276 | |
| 277 | if (loadInfo->isValid()) |
| 278 | { |
| 279 | char *thread_print_name = nullptr; |
| 280 | if (thread_name_list) |
| 281 | { |
| 282 | JKRThreadName_ *thread_name = thread_name_list; |
| 283 | for (; thread_name->name; thread_name++) |
| 284 | { |
| 285 | if (thread_name->id == loadInfo->getId()) |
| 286 | { |
| 287 | thread_print_name = thread_name->name; |
| 288 | break; |
| 289 | } |
| 290 | } |
| 291 | } |
| 292 | |
| 293 | if (!thread_print_name) |
| 294 | { |
| 295 | char buffer[16]; |
| 296 | sprintf(buffer, "%d", loadInfo->getId()); |
| 297 | thread_print_name = buffer; |
| 298 | } |
| 299 | |
| 300 | u32 switch_count = loadInfo->getCount(); |
| 301 | float cost_per_0x18 = loadInfo->getCost() / (float)_18; |
| 302 | |
| 303 | u32 cost_int = (u32)(cost_per_0x18 * 100.0f); |
| 304 | u32 cost_float = (u32)(cost_per_0x18 * 1000.0f) % 10; |
| 305 | if (!console) |
| 306 | { |
| 307 | /*#if DEBUG |
| 308 | OSReport(" [%10s] switch:%5d cost:%2d.%d%%\n", thread_print_name, switch_count, |
| 309 | cost_int, cost_float); |
| 310 | #endif*/ |
nothing calls this directly
no test coverage detected