iOS - Get CPU usage from application
问题 Does anyone know how to obtain CPU usage for an application? It's definitely possible, because there are application in app store (Activity Monitor Touch) which can show it. 回答1: Update . This code is working for me: Update 2 . The thread_list was leaking, so added vm_deallocate #import <mach/mach.h> #import <assert.h> float cpu_usage() { kern_return_t kr; task_info_data_t tinfo; mach_msg_type_number_t task_info_count; task_info_count = TASK_INFO_MAX; kr = task_info(mach_task_self(), TASK