ÔõÑùÔÚLinuxϵͳÖÐʹÓÃCoreFreqÀ´¼à¿ØCPUÐÔÄÜ£¿
ÔõÑùÔÚLinuxϵͳÖÐʹÓÃCoreFreqÀ´¼à¿ØCPUÐÔÄÜ£¿
ÔÚLinuxϵͳÖУ¬ÎÒÃǾ³£ÐèÒª¼à¿ØCPUµÄÐÔÄÜÒÔÈ·±£ÏµÍ³ÔËÐеÄÎȹÌÐԺ͸ßЧÐÔ¡£CoreFreqÊÇÒ»¸ö¿ªÔ´¹¤¾ß£¬¿ÉÒÔ×ÊÖúÎÒÃÇʵʱ¼à¿ØCPUµÄÐÔÄÜÖ¸±ê£¬°üÀ¨ÆµÂÊ¡¢¸ºÔØ¡¢Î¶ȵÈÐÅÏ¢¡£±¾ÎĽ«ÏêϸÏÈÈÝÔõÑùÔÚLinuxϵͳÖÐ×°ÖúÍʹÓÃCoreFreq£¬²¢Í¨¹ýÏêϸ´úÂëʾÀýÑÝʾÔõÑù¼à¿ØCPUÐÔÄÜ¡£
1. ×°ÖÃCoreFreq
Ê×ÏÈ£¬ÎÒÃÇÐèÒªÏÂÔز¢×°ÖÃCoreFreq¹¤¾ß¡£¿ÉÒÔͨ¹ýÒÔÏ°취ÔÚLinuxϵͳÖÐ×°ÖÃCoreFreq£º
$ git clone https://github.com/cyring/CoreFreq.git $ cd CoreFreq $ make $ sudo make load
µÇ¼ºó¸´ÖÆ
ÒÔÉÏÏÂÁ»á´ÓGitHubÉÏÏÂÔØCoreFreqµÄ´úÂ룬²¢±àÒë×°Ö᣽Ó×Åͨ¹ýsudo make loadÏÂÁî¼ÓÔØCoreFreqÄÚºËÄ£¿é¡£
2. Éó²éCPUÐÅÏ¢
×°ÖÃÍê³Éºó£¬ÎÒÃÇ¿ÉÒÔʹÓÃÒÔÏÂÏÂÁîÉó²éCPUµÄ»ù±¾ÐÅÏ¢£º
$ corefreq-cli -i
µÇ¼ºó¸´ÖÆ
¸ÃÏÂÁÁгöCPUµÄÖÖÖÖÐÅÏ¢£¬°üÀ¨CPUÐͺš¢ÆµÂÊ¡¢½¹µãÊýÄ¿µÈ¡£
3. ʵʱ¼à¿ØCPUÐÔÄÜ
ÏÖÔÚÎÒÃÇÒѾװÖò¢Éó²éÁËCPUµÄ»ù±¾ÐÅÏ¢£¬½ÓÏÂÀ´ÎÒÃÇ¿ÉÒÔʹÓÃCoreFreqʵʱ¼à¿ØCPUµÄÐÔÄÜ¡£
$ corefreq-cli -C
µÇ¼ºó¸´ÖÆ
¸ÃÏÂÁÆô¶¯CoreFreqµÄ¿ØÖÆ̨ģʽ£¬¿ÉÒÔʵʱÏÔʾCPUµÄƵÂÊ¡¢¸ºÔØ¡¢Î¶ȵÈÖ¸±ê¡£ÎÒÃÇ¿ÉÒÔͨ¹ý°´ÏÂq¼üÍ˳ö¿ØÖÆ̨ģʽ¡£
4. дһ¸ö¼òÆӵĽÅÔÀ´ÊµÊ±¼à¿ØCPUÐÔÄÜ
ÈôÊÇÏëÒª½«ÊµÊ±¼à¿ØCPUÐÔÄܵÄЧ¹ûÊä³öµ½ÎļþÖУ¬ÎÒÃÇ¿ÉÒÔ±àдһ¸ö¼òÆÓµÄShell½ÅÔÀ´ÊµÏÖ¡£
ÒÔÏÂÊÇÒ»¸öÀý×Ó£¬½«CPUµÄÐÔÄÜÖ¸±êÊä³öµ½cpu_performance.logÎļþÖУº
#!/bin/bash while true do corefreq-cli -s >> cpu_performance.log sleep 1 done
µÇ¼ºó¸´ÖÆ
½«ÒÔÉÏ´úÂëÉúÑĵ½Ò»¸ö¾ç±¾Îļþ£¨Èçmonitor_cpu.sh£©£¬È»ºóÔËÐÐÒÔÏÂÏÂÁ
$ chmod +x monitor_cpu.sh $ ./monitor_cpu.sh
µÇ¼ºó¸´ÖÆ
ÔËÐиþ籾ºó£¬CPUµÄÐÔÄÜÖ¸±ê½«»áÿÃëÊä³öµ½cpu_performance.logÎļþÖС£
ͨ¹ýÒÔÉÏÒªÁ죬ÎÒÃÇ¿ÉÒÔÀû±ãµØʹÓÃCoreFreq¹¤¾ßÀ´¼à¿ØCPUµÄÐÔÄÜ£¬ÓÐÖúÓÚÎÒÃÇʵʱ·¢Ã÷Ï¢Õù¾öϵͳÐÔÄÜÎÊÌ⡣ϣÍû±¾ÎĶÔÄúÓÐËù×ÊÖú£¡
ÒÔÉϾÍÊÇÔõÑùÔÚLinuxϵͳÖÐʹÓÃCoreFreqÀ´¼à¿ØCPUÐÔÄÜ£¿µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡