- Timestamp:
- 2010-06-11T12:41:35Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- b3b7e14a
- Parents:
- 48dcc69
- Location:
- uspace/app/top
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/top/screen.c
r48dcc69 rbe06914 126 126 } 127 127 128 static void print_ float(fixed_float ffloat, unsigned int precision)129 { 130 printf("% 2" PRIu64 ".", ffloat.upper / ffloat.lower);128 static void print_percent(fixed_float ffloat, unsigned int precision) 129 { 130 printf("%3" PRIu64 ".", ffloat.upper / ffloat.lower); 131 131 132 132 unsigned int i; … … 136 136 rest = (rest % ffloat.lower) * 10; 137 137 } 138 139 printf("%%"); 140 } 141 142 static void print_string(const char *str) 143 { 144 ipcarg_t cols; 145 ipcarg_t rows; 146 screen_get_size(&cols, &rows); 147 148 ipcarg_t c; 149 ipcarg_t r; 150 screen_get_pos(&c, &r); 151 152 if (c < cols) 153 printf("%.*s", cols - c - 1, str); 138 154 } 139 155 … … 211 227 data->cpus[i].busy_ticks, data->cpus[i].idle_ticks); 212 228 puts(", idle: "); 213 print_float(data->cpus_perc[i].idle, 2); 214 puts("%, busy: "); 215 print_float(data->cpus_perc[i].busy, 2); 216 puts("%"); 229 print_percent(data->cpus_perc[i].idle, 2); 230 puts(", busy: "); 231 print_percent(data->cpus_perc[i].busy, 2); 217 232 } else 218 233 printf("cpu%u inactive", data->cpus[i].id); … … 247 262 { 248 263 screen_style_inverted(); 249 printf(" ID Threads Mem %%Mem %%uCycles %%kCycles Name"); 264 printf("[taskid] [threads] [virtual] [%%virt] [%%user]" 265 " [%%kernel] [name"); 250 266 screen_newline(); 251 267 screen_style_normal(); … … 268 284 order_suffix(data->tasks[i].virtmem, &virtmem, &virtmem_suffix); 269 285 270 printf("% 8" PRIu64 " %8u %8" PRIu64 "%c ", data->tasks[i].task_id,286 printf("%-8" PRIu64 " %9u %8" PRIu64 "%c ", data->tasks[i].task_id, 271 287 data->tasks[i].threads, virtmem, virtmem_suffix); 288 print_percent(data->tasks_perc[i].virtmem, 2); 289 puts(" "); 290 print_percent(data->tasks_perc[i].ucycles, 2); 272 291 puts(" "); 273 print_float(data->tasks_perc[i].virtmem, 2); 274 puts("% "); 275 print_float(data->tasks_perc[i].ucycles, 2); 276 puts("% "); 277 print_float(data->tasks_perc[i].kcycles, 2); 278 printf("%% %s", data->tasks[i].name); 292 print_percent(data->tasks_perc[i].kcycles, 2); 293 puts(" "); 294 print_string(data->tasks[i].name); 279 295 280 296 screen_newline(); … … 290 306 { 291 307 screen_style_inverted(); 292 printf(" ID Calls sent Calls recv Answs sent Answs recv IRQn recv Forw Name"); 308 printf("[taskid] [cls snt] [cls rcv] [ans snt]" 309 " [ans rcv] [irq rcv] [forward] [name"); 293 310 screen_newline(); 294 311 screen_style_normal(); … … 307 324 size_t i; 308 325 for (i = 0; (i < data->tasks_count) && (row < rows); i++, row++) { 309 printf("%8" PRIu64 " %10" PRIu64 " %10" PRIu64 " %10" PRIu64 310 " %10" PRIu64 " %10" PRIu64 " %10" PRIu64 " %s", 311 data->tasks[i].task_id, data->tasks[i].ipc_info.call_sent, 312 data->tasks[i].ipc_info.call_recieved, 313 data->tasks[i].ipc_info.answer_sent, 314 data->tasks[i].ipc_info.answer_recieved, 315 data->tasks[i].ipc_info.irq_notif_recieved, 316 data->tasks[i].ipc_info.forwarded, data->tasks[i].name); 326 uint64_t call_sent; 327 uint64_t call_received; 328 uint64_t answer_sent; 329 uint64_t answer_received; 330 uint64_t irq_notif_received; 331 uint64_t forwarded; 332 333 char call_sent_suffix; 334 char call_received_suffix; 335 char answer_sent_suffix; 336 char answer_received_suffix; 337 char irq_notif_received_suffix; 338 char forwarded_suffix; 339 340 order_suffix(data->tasks[i].ipc_info.call_sent, &call_sent, 341 &call_sent_suffix); 342 order_suffix(data->tasks[i].ipc_info.call_received, 343 &call_received, &call_received_suffix); 344 order_suffix(data->tasks[i].ipc_info.answer_sent, 345 &answer_sent, &answer_sent_suffix); 346 order_suffix(data->tasks[i].ipc_info.answer_received, 347 &answer_received, &answer_received_suffix); 348 order_suffix(data->tasks[i].ipc_info.irq_notif_received, 349 &irq_notif_received, &irq_notif_received_suffix); 350 order_suffix(data->tasks[i].ipc_info.forwarded, &forwarded, 351 &forwarded_suffix); 352 353 printf("%-8" PRIu64 " %8" PRIu64 "%c %8" PRIu64 "%c" 354 " %8" PRIu64 "%c %8" PRIu64 "%c %8" PRIu64 "%c" 355 " %8" PRIu64 "%c ", data->tasks[i].task_id, 356 call_sent, call_sent_suffix, 357 call_received, call_received_suffix, 358 answer_sent, answer_sent_suffix, 359 answer_received, answer_received_suffix, 360 irq_notif_received, irq_notif_received_suffix, 361 forwarded, forwarded_suffix); 362 print_string(data->tasks[i].name); 317 363 318 364 screen_newline(); … … 328 374 { 329 375 screen_style_inverted(); 330 printf(" ID Desc Count Cycles");376 printf("[exc ] [count ] [%%count] [cycles ] [%%cycles] [description"); 331 377 screen_newline(); 332 378 screen_style_normal(); … … 345 391 size_t i; 346 392 for (i = 0; (i < data->exceptions_count) && (row < rows); i++, row++) { 393 uint64_t count; 347 394 uint64_t cycles; 348 char suffix; 349 350 order_suffix(data->exceptions[i].cycles, &cycles, &suffix); 351 printf("%8u %20s %8" PRIu64 " %8" PRIu64 "%c", 352 data->exceptions[i].id, data->exceptions[i].desc, 353 data->exceptions[i].count, cycles, suffix); 395 396 char count_suffix; 397 char cycles_suffix; 398 399 order_suffix(data->exceptions[i].count, &count, &count_suffix); 400 order_suffix(data->exceptions[i].cycles, &cycles, &cycles_suffix); 401 402 printf("%-8u %9" PRIu64 "%c ", 403 data->exceptions[i].id, count, count_suffix); 404 print_percent(data->exceptions_perc[i].count, 2); 405 printf(" %9" PRIu64 "%c ", cycles, cycles_suffix); 406 print_percent(data->exceptions_perc[i].cycles, 2); 407 puts(" "); 408 print_string(data->exceptions[i].desc); 354 409 355 410 screen_newline(); -
uspace/app/top/top.c
r48dcc69 rbe06914 67 67 target->tasks_perc = NULL; 68 68 target->threads = NULL; 69 target->exceptions = NULL; 70 target->exceptions_perc = NULL; 69 71 target->physmem = NULL; 70 72 … … 115 117 return "Cannot get threads"; 116 118 119 /* Get Exceptions */ 117 120 target->exceptions = stats_get_exceptions(&(target->exceptions_count)); 118 121 if (target->exceptions == NULL) 119 122 return "Cannot get exceptions"; 123 124 target->exceptions_perc = 125 (perc_exc_t *) calloc(target->exceptions_count, sizeof(perc_exc_t)); 126 if (target->exceptions_perc == NULL) 127 return "Not enough memory for exception utilization"; 120 128 121 129 /* Get physical memory */ … … 137 145 /* Allocate memory */ 138 146 139 uint64_t *ucycles_diff = calloc(new_data->tasks_count, sizeof(uint64_t)); 147 uint64_t *ucycles_diff = calloc(new_data->tasks_count, 148 sizeof(uint64_t)); 140 149 if (ucycles_diff == NULL) 141 150 return "Not enough memory for user utilization"; 142 151 143 uint64_t *kcycles_diff = calloc(new_data->tasks_count, sizeof(uint64_t)); 152 uint64_t *kcycles_diff = calloc(new_data->tasks_count, 153 sizeof(uint64_t)); 144 154 if (kcycles_diff == NULL) { 145 155 free(ucycles_diff); 146 156 return "Not enough memory for kernel utilization"; 157 } 158 159 uint64_t *ecycles_diff = calloc(new_data->exceptions_count, 160 sizeof(uint64_t)); 161 if (ecycles_diff == NULL) { 162 free(ucycles_diff); 163 free(kcycles_diff); 164 return "Not enough memory for exception cycles utilization"; 165 } 166 167 uint64_t *ecount_diff = calloc(new_data->exceptions_count, 168 sizeof(uint64_t)); 169 if (ecount_diff == NULL) { 170 free(ucycles_diff); 171 free(kcycles_diff); 172 free(ecycles_diff); 173 return "Not enough memory for exception count utilization"; 147 174 } 148 175 … … 164 191 /* For all tasks compute sum and differencies of all cycles */ 165 192 166 uint64_t virtmem_total = 1; /* Must NOT be zero */167 uint64_t ucycles_total = 1; /* Must NOT be zero */168 uint64_t kcycles_total = 1; /* Must NOT be zero */193 uint64_t virtmem_total = 0; 194 uint64_t ucycles_total = 0; 195 uint64_t kcycles_total = 0; 169 196 170 197 for (i = 0; i < new_data->tasks_count; i++) { … … 197 224 } 198 225 199 /* For each task : Compute percential change */226 /* For each task compute percential change */ 200 227 201 228 for (i = 0; i < new_data->tasks_count; i++) { … … 208 235 } 209 236 237 /* For all exceptions compute sum and differencies of cycles */ 238 239 uint64_t ecycles_total = 0; 240 uint64_t ecount_total = 0; 241 242 for (i = 0; i < new_data->exceptions_count; i++) { 243 /* 244 * March exception with the previous instance. 245 * This is quite paranoid since exceptions do not 246 * usually disappear, but it does not hurt. 247 */ 248 249 bool found = false; 250 size_t j; 251 for (j = 0; j < old_data->exceptions_count; j++) { 252 if (new_data->exceptions[i].id == old_data->exceptions[j].id) { 253 found = true; 254 break; 255 } 256 } 257 258 if (!found) { 259 /* This is a new exception, ignore it */ 260 ecycles_diff[i] = 0; 261 ecount_diff[i] = 0; 262 continue; 263 } 264 265 ecycles_diff[i] = 266 new_data->exceptions[i].cycles - old_data->exceptions[j].cycles; 267 ecount_diff[i] = 268 new_data->exceptions[i].count - old_data->exceptions[i].count; 269 270 ecycles_total += ecycles_diff[i]; 271 ecount_total += ecount_diff[i]; 272 } 273 274 /* For each exception compute percential change */ 275 276 for (i = 0; i < new_data->exceptions_count; i++) { 277 FRACTION_TO_FLOAT(new_data->exceptions_perc[i].cycles, 278 ecycles_diff[i] * 100, ecycles_total); 279 FRACTION_TO_FLOAT(new_data->exceptions_perc[i].count, 280 ecount_diff[i] * 100, ecount_total); 281 } 282 210 283 /* Cleanup */ 211 284 212 285 free(ucycles_diff); 213 286 free(kcycles_diff); 287 free(ecycles_diff); 288 free(ecount_diff); 214 289 215 290 return NULL; … … 238 313 if (target->exceptions != NULL) 239 314 free(target->exceptions); 315 316 if (target->exceptions_perc != NULL) 317 free(target->exceptions_perc); 240 318 241 319 if (target->physmem != NULL) -
uspace/app/top/top.h
r48dcc69 rbe06914 39 39 #include <time.h> 40 40 41 #define FRACTION_TO_FLOAT(float, a, b) { \ 42 (float).upper = (a); \ 43 (float).lower = (b); \ 44 } 41 #define FRACTION_TO_FLOAT(float, a, b) \ 42 { \ 43 if ((b) != 0) { \ 44 (float).upper = (a); \ 45 (float).lower = (b); \ 46 } else { \ 47 (float).upper = 0; \ 48 (float).lower = 1; \ 49 } \ 50 } 45 51 46 52 #define OP_TASKS 1 … … 61 67 62 68 typedef struct { 69 fixed_float virtmem; 63 70 fixed_float ucycles; 64 71 fixed_float kcycles; 65 fixed_float virtmem;66 72 } perc_task_t; 73 74 typedef struct { 75 fixed_float cycles; 76 fixed_float count; 77 } perc_exc_t; 67 78 68 79 typedef struct { … … 92 103 size_t exceptions_count; 93 104 stats_exc_t *exceptions; 105 perc_exc_t *exceptions_perc; 94 106 95 107 stats_physmem_t *physmem;
Note:
See TracChangeset
for help on using the changeset viewer.