{"id":1045,"date":"2015-03-23T18:15:27","date_gmt":"2015-03-23T10:15:27","guid":{"rendered":"http:\/\/www.yeetrack.com\/?p=1045"},"modified":"2015-03-23T18:15:27","modified_gmt":"2015-03-23T10:15:27","slug":"android-cpu%e8%80%97%e7%94%b5%e9%87%8f%e6%b5%8b%e8%af%95","status":"publish","type":"post","link":"https:\/\/www.yeetrack.com\/?p=1045","title":{"rendered":"Android CPU\u8017\u7535\u91cf\u6d4b\u8bd5"},"content":{"rendered":"<h1>Android CPU\u8017\u7535\u91cf\u6d4b\u8bd5<\/h1>\n<p>\u5728\u6d4b\u8bd5Android app\u65f6\uff0c\u4e0d\u4ec5\u4ec5\u8981\u5173\u6ce8app\u7684\u529f\u80fd\uff0c\u4e5f\u597d\u5173\u6ce8app\u7684\u6027\u80fd\u6307\u6807\uff0ccpu\u3001\u5185\u5b58\u3001\u6d41\u91cf\u3001\u7535\u91cf\u7b49\u3002\u7b80\u5355\u4ecb\u7ecd\u4e0b\u7535\u91cf\u6d4b\u8bd5\u4e2d\u7684cpu\u8017\u7535\u3002<\/p>\n<h2>\u5f71\u54cd\u8017\u7535\u7684\u56e0\u7d20<\/h2>\n<ul>\n<li>CPU<\/li>\n<li>Screen<\/li>\n<li>Network (3G\/wifi)<\/li>\n<li>sensor &amp; gps<\/li>\n<li>WakeLock<\/li>\n<li>...<\/li>\n<\/ul>\n<p><!--more--><\/p>\n<h2>\u7535\u91cf\u6d4b\u8bd5\u65b9\u6cd5<\/h2>\n<ol>\n<li>\u5b89\u88c5\u7535\u6c60\u7ba1\u7406\u7684\u8f6f\u4ef6\uff0c\u7ba1\u5bb6\u3001\u536b\u58eb\u4e00\u7c7b\u7684\u8f6f\u4ef6\u3002<\/li>\n<li>\u81ea\u5df1\u8bfb\u53d6Android\u7684\u5185\u6838\u65e5\u5fd7\uff0c\u7535\u91cf\u53d8\u5316\u5e7f\u64ad\u7b49\u3002<\/li>\n<li>\u7269\u7406\u8bbe\u5907\uff0c\u5b89\u57f9\u8f6e\u7b49<\/li>\n<\/ol>\n<p>\u8fd9\u91cc\u4e3b\u8981\u4ecb\u7ecd\u8bfb\u53d6\u5185\u6838\u6587\u4ef6\uff0c\u8ba1\u7b97\u51facpu\u7684\u7535\u91cf\u6d88\u8017\u3002<\/p>\n<p>\u6b65\u9aa4\u4e3b\u8981\u5982\u4e0b\uff1a<\/p>\n<ol>\n<li>\u6293\u53d6\u6307\u5b9aapp\u5360\u7528\u7684cpu\u65f6\u95f4<\/li>\n<li>\u83b7\u53d6cpu\u5728\u5404\u4e2a\u9891\u7387\u4e0b\u7684\u8fd0\u884c\u65f6\u95f4<\/li>\n<li>\u6839\u636e\u4e0d\u540c\u9891\u7387\u4e0b\u7684\u4e0d\u540c\u8017\u7535\u529f\u7387\uff0c\u8ba1\u7b97\u51fa\u603b\u7684\u8017\u7535\u6d88\u8017\u3002<\/li>\n<\/ol>\n<h3>power_profile.xml<\/h3>\n<p>\u6bcf\u4e2aAndroid\u8bbe\u5907\u90fd\u5b58\u5728\u8fd9\u6837\u7684\u4e00\u4e2a\u6587\u4ef6\uff0c\u8fd9\u4e2a\u6587\u4ef6\u5b9a\u4e49\u4e86\u5404\u4e2a\u786c\u4ef6\u7684\u529f\u7387\u3002\u4e0d\u540c\u7684\u624b\u673a\uff0c\u5185\u5bb9\u4e0d\u540c\u3002\u6211\u7684\u5982\u4e0b\uff08\u5355\u4f4dmAh\uff0c\u610f\u601d\u662f\u4e00\u4e2a\u5c0f\u65f6\uff0c\u80fd\u8017\u7535\u591a\u5c11mAh\uff09\uff1a<\/p>\n<pre><code>    &lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;\n    &lt;device name=\"Android\"&gt;\n        &lt;item name=\"none\"&gt;0&lt;\/item&gt;\n        &lt;item name=\"screen.on\"&gt;71&lt;\/item&gt;\n        &lt;item name=\"bluetooth.active\"&gt;17&lt;\/item&gt;\n        &lt;item name=\"bluetooth.on\"&gt;0.3&lt;\/item&gt;\n        &lt;item name=\"screen.full\"&gt;380&lt;\/item&gt;\n        &lt;item name=\"wifi.on\"&gt;0.3&lt;\/item&gt;\n        &lt;item name=\"wifi.active\"&gt;96&lt;\/item&gt;\n        &lt;item name=\"wifi.scan\"&gt;70&lt;\/item&gt;\n        &lt;item name=\"dsp.audio\"&gt;44&lt;\/item&gt;\n        &lt;item name=\"dsp.video\"&gt;280&lt;\/item&gt;\n        &lt;item name=\"radio.active\"&gt;250&lt;\/item&gt;\n        &lt;item name=\"radio.scanning\"&gt;82&lt;\/item&gt;\n        &lt;item name=\"gps.on\"&gt;1&lt;\/item&gt;\n        &lt;array name=\"radio.on\"&gt;\n            &lt;value&gt;3.4&lt;\/value&gt;\n            &lt;value&gt;3.4&lt;\/value&gt;\n        &lt;\/array&gt;\n        &lt;array name=\"cpu.speeds\"&gt;\n            &lt;value&gt;12000000&lt;\/value&gt;\n            &lt;value&gt;10000000&lt;\/value&gt;\n            &lt;value&gt;800000&lt;\/value&gt;\n            &lt;value&gt;500000&lt;\/value&gt;\n            &lt;value&gt;200000&lt;\/value&gt;\n        &lt;\/array&gt;\n        &lt;item name=\"cpu.idle\"&gt;4&lt;\/item&gt;\n            &lt;array name=\"cpu.active\"&gt;\n            &lt;value&gt;577&lt;\/value&gt;\n            &lt;value&gt;408&lt;\/value&gt;\n            &lt;value&gt;249&lt;\/value&gt;\n            &lt;value&gt;148&lt;\/value&gt;\n            &lt;value&gt;55&lt;\/value&gt;\n        &lt;\/array&gt;\n        &lt;item name=\"battery.capacity\"&gt;2100&lt;\/item&gt;\n    &lt;\/device&gt;\n<\/code><\/pre>\n<h4>\u5982\u4f55\u5f97\u5230power_profile.xml\u6587\u4ef6<\/h4>\n<p>\u8be5\u6587\u4ef6\u5b58\u5728\u624b\u673a\u7684\/system\/framework\/framework-res.apk\u5305\u91cc\uff0c\u9700\u8981\u4f7f\u7528apk-tool\u5bf9apk\u8fdb\u884c\u53cd\u7f16\u8bd1\uff0c\u53cd\u7f16\u8bd1\u540e\uff0c\u5728$output\/res\/xml\u6587\u4ef6\u5939\u4e2d\u3002<\/p>\n<h3>\u83b7\u53d6app\u6267\u884c\u65f6\u95f4<\/h3>\n<ol>\n<li>\u83b7\u53d6pid\uff0c <code>adb shell ps | grep {appName}<\/code>\u6216\u8005<code>adb shell top -n 1 | grep ${appName}<\/code><\/li>\n<li>\u83b7\u53d6pid\u6267\u884c\u65f6\u95f4\uff0c<code>cat \/proc\/${pid}\/stat<\/code>, \u8fd9\u4e2a\u6587\u4ef6\u4e2d\u7684\u7b2c14\u5217\u523017\u5217\u76f8\u52a0\u5f97\u5230\u7684\u5c31\u662f\u4ece\u5f00\u673a\u5230\u6b64\u523b\uff0capp\u4e00\u5171\u5360\u7528\u591a\u5c11cpu\u65f6\u95f4\uff08\u8bbe\u8fd9\u91cc\u503c\u4e3aT1\uff09\uff0c\u8fd9\u91cc\u7684\u5355\u4f4d\u662fjiffies, \u8fd9\u4e2a\u5355\u4f4d\u7684\u610f\u601d\u662fcpu\u7684\u8fd0\u7b97\u6b21\u6570\uff0c\u5982\u679ccpu\u7684\u9891\u7387\u4e3a1G\uff0c\u90a3\u4e481 jiffies = 1\/1G \u79d2\u3002<\/li>\n<li>\u4e0d\u65ad\u53bb<code>cat \/proc\/${pid}\/stat<\/code>,\u83b7\u53d6cpu\u5360\u7528\u65f6\u95f4\uff0c\u51cf\u53bb\u7b2c\u4e8c\u6b65\u7684T1\uff0c\u5c31\u662f\u8fd9\u6bb5\u65f6\u95f4app\u7684cpu\u5360\u7528\u65f6\u95f4\u3002<\/li>\n<li>\u83b7\u53d6cpu\u5728\u4e0d\u540c\u9891\u7387\u4e0b\u7684\u5de5\u4f5c\u51e0\u7387\u3002android\u7684cpu\u4f1a\u5728\u4e0d\u540c\u4e3b\u9891\u4e0b\u5de5\u4f5c\uff0c\/sys\/devices\/system\/cpu\/cpu0\/cpufreq\/stats\/time_instate<br \/>\n\u653e\u4e86cpu\u5728\u5404\u4e2a\u9891\u6bb5\u7684\u5360\u7528\u65f6\u95f4,\u6ce8\u610f\u662f\u6574\u4e2a\u7cfb\u7edf\u5360\u7528\u65f6\u95f4\uff0c\u6839\u636e\u8fd9\u4e2a\u51e0\u7387\uff0c\u8ba1\u7b97\u51facpu\u7684\u6bcf\u4e2a\u9891\u7387\u4e0b\u7684\u5de5\u4f5c\u65f6\u95f4\uff0c\u7136\u540e\u518d\u4e58\u4ee5power_profile.xml\u4e2d\u5b9a\u4e49\u7684\u5355\u4f4d\u8017\u7535\uff0c\u7d2f\u52a0\u5f97\u5230cpu\u6d88\u8017\u3002<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>Android CPU\u8017\u7535\u91cf\u6d4b\u8bd5 \u5728\u6d4b\u8bd5Android app\u65f6\uff0c\u4e0d\u4ec5\u4ec5\u8981\u5173\u6ce8app\u7684\u529f\u80fd\uff0c\u4e5f\u597d\u5173\u6ce8app\u7684\u6027\u80fd\u6307\u6807\uff0ccpu\u3001\u5185\u5b58\u3001\u6d41\u91cf\u3001\u7535\u91cf\u7b49\u3002\u7b80\u5355\u4ecb\u7ecd\u4e0b\u7535\u91cf\u6d4b\u8bd5\u4e2d\u7684cpu\u8017\u7535\u3002 \u5f71\u54cd\u8017\u7535\u7684\u56e0\u7d20 C&#46;&#46;&#46;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"pgc_sgb_lightbox_settings":"","footnotes":""},"categories":[34],"tags":[43,49,42,41],"class_list":["post-1045","post","type-post","status-publish","format-standard","hentry","category-software","tag-android","tag-49","tag-42","tag-41"],"views":17101,"_links":{"self":[{"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=\/wp\/v2\/posts\/1045","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1045"}],"version-history":[{"count":1,"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=\/wp\/v2\/posts\/1045\/revisions"}],"predecessor-version":[{"id":1046,"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=\/wp\/v2\/posts\/1045\/revisions\/1046"}],"wp:attachment":[{"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1045"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1045"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1045"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}