Linux узнать скорость процессора

What is the correct way to view your CPU speed on Linux?

I found two commands to output information about my CPU: cat /proc/cpuinfo and lscpu . /proc/cpuinfo shows that my CPU speed is 2.1 Ghz, whereas lspcu says it is 3167 Mhz. Which one is correct? This is my exact output from cat /proc/cpuinfo about my processor speed:

model name : Intel(R) Core(TM) i7-4600U CPU @ 2.10GHz 

Your /proc/cpuinfo should also have a line that says cpu MHZ: . which is the current speed. The 2.1 after the @ is the base speed (without turbo boost).

It’s Intel’s way of «hitting the gas» when needed. I guess your actual speed at the time was indeed around 3.2 GHz, you could also try e.g. for cpu0 with cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq (as root).

Turbo Boost is a technology that changes the frequency of the processor depending of the number of cores you are using. If you use few cores, the frequency is increased to boost the performance and maintain a low temperature. You may check the Turbo Boost frequency tables to check how it increases.

6 Answers 6

To see the current speed of each core I do this:

watch -n.1 "grep \"^[c]pu MHz\" /proc/cpuinfo" 

This does not work on server CPUs such as the Intel Xeon series. On such machines it will show the base frequency only. To show the turbo frequency, you’ll need cpupower or turbostat. See @Maxim Egorushkin’s answer.

If your watch command does not work with intervals smaller than one second, modify the interval like so:

watch -n1 "grep \"^[c]pu MHz\" /proc/cpuinfo" 

This displays the cpu speed of each core in real time.

By running the following command, one or more times, from another terminal one can see the speed change with the above watch command, assuming SpeedStep is enabled ( Cool’n’Quiet for AMD ).

echo "scale=10000; 4*a(1)" | bc -l & 

(This command uses bc to calculate pi to 10000 places.)

I had to remove the . in your first command to make it work: watch -n1 «cat /proc/cpuinfo | grep \»^[c]pu MHz\»»

this is a nifty way to do it, but I’d caution against running any command every .1 seconds, that is itself going to impact the cpu speed report. 1 second is plenty.

@Lizardx Ordinarily I agree but in this case the CPU speed can increase and decrease faster than a 1 second interval, resulting in a lack of visible speed changes. Since modern processors are so fast, I initially thought my SpeedStep was not working when using 1 second as the interval. At a minimum, .5 should be used if one doesn’t want to go as fast as .1 second (although I have still missed seeing many of the speed changes at that rate.

Читайте также:  Изменить mime type файла linux

Try running top with the timers set to less than 1 second, you can see the cpu usage visibly. My guess is that what you may actually be seeing is the system generating your cpu speed info, that is, the generation of the cpu speed output is causing the cpu movement. I find that anything less than a second starts to directly cause the cpu speeds you are watching. For example, top at -d5 is 1% of cpu. At -d2 it’s about 5%. You might find you’re actually fooling yourself into thinking the cpu is doing something that you’re making it do, heh. Output to shell is expensive too.

Could try watch -n0.1 , might work. Failing that, while true; do cat /proc/cpuinfo | grep MHz; sleep 0.1; clear; done , it flickers more than watch though.

For intel i3, i5 and i7 based cpus there is a dedicated tool called i7z that shows current speed for all cpu cores.

From man page (description):

i7z runs the i7z, ncurses based, program without any options. i7z will print out the C-states and temperature for i3, i5 and i7 based Core processors from Intel (including Nehalems, Sandy Bridge and Ivy Bridge).

For ubuntu-based distributions you can install it by issuing this command:

then just run it (tool needs to be run with sudo):

This is the best solution if you have an Intel CPU. Cat’ing the cpuinfo gives you incorrect clock speeds. Just a note, you forgot to put the dash in «apt-get».

Well. it works with my Xeon processor only the output is garbled, maybe because I have two CPUs (I have a dual Xeon motherboard).

Unfortunately, i7z doesn’t seem to work properly on my Core i7-1165G7 – it says «unknown processor» (among other things) and aborts.

Another good tool from Intel itself is turbostat (from the linux-cpupower package). But this one has nicer output.

The Intel Core i7-4600U Processor supports Turbo Boost technology. It has a base frequency of 2.10GHz and a Max Turbo Frequency of 3.30GHz. That means that,

  • If you disable the Turbo Boost (in the BIOS setup menu), the CPU will work at 2.10GHz all the time.
  • When Turbo Boost is enabled and only one of the cores is working, the CPU will work at a maximum of 3.30GHz.
  • If Turbo Boost is enabled and all the cores are working, the CPU will work at 2.10GHz.

Obtaining current frequency

To determine if the Turbo Boost is activated and which is the current frequency, you can use cpupower frequency-info . For instance, for an old Intel Core i5-660 with Turbo Boost enabled, you will get the following.

$ cpupower frequency-info analyzing CPU 0: driver: acpi-cpufreq CPUs which run at the same hardware frequency: 0 CPUs which need to have their frequency coordinated by software: 0 maximum transition latency: 10.0 us. hardware limits: 1.20 GHz - 3.47 GHz available frequency steps: 3.47 GHz, 3.33 GHz, 2.53 GHz, 1.87 GHz, 1.20 GHz available cpufreq governors: conservative, ondemand, userspace, powersave, performance current policy: frequency should be within 1.20 GHz and 3.47 GHz. The governor "ondemand" may decide which speed to use within this range. current CPU frequency is 1.87 GHz. cpufreq stats: 3.47 GHz:82,67%, 3.33 GHz:0,00%, 2.53 GHz:0,00%, 1.87 GHz:0,06%, 1.20 GHz:17,28% (3) boost state support: Supported: yes Active: yes 25500 MHz max turbo 4 active cores 25500 MHz max turbo 3 active cores 25500 MHz max turbo 2 active cores 25500 MHz max turbo 1 active cores 

Note that the information states the hardware limits ( 1.20 GHz — 3.47 GHz ), the possible frequencies ( 3.47 GHz, 3.33 GHz, 2.53 GHz, 1.87 GHz, 1.20 GHz ) and the current frequency ( 1.87 GHz ). You may find the technical information of these frequencies at the Intel website.

Читайте также:  Linux rdp win 10

Frequency when TurboBoost is disabled

Note the difference when you run the same command with Turbo Boost disabled: In the boost state support section, the values for Supported and Active are no . Here, the CPU will be at the nominal/minimal value (1.20Ghz) all the time.

$ cpupower frequency-info analyzing CPU 0: driver: acpi-cpufreq CPUs which run at the same hardware frequency: 0 CPUs which need to have their frequency coordinated by software: 0 maximum transition latency: 10.0 us. hardware limits: 1.20 GHz - 3.47 GHz available frequency steps: 3.47 GHz, 3.33 GHz, 2.53 GHz, 1.87 GHz, 1.20 GHz available cpufreq governors: conservative, ondemand, userspace, powersave, performance current policy: frequency should be within 1.20 GHz and 3.47 GHz. The governor "ondemand" may decide which speed to use within this range. current CPU frequency is 1.20 GHz. cpufreq stats: 3.47 GHz:40,86%, 3.33 GHz:0,01%, 2.53 GHz:0,06%, 1.87 GHz:0,22%, 1.20 GHz:58,85% (493) boost state support: Supported: no Active: no 25500 MHz max turbo 4 active cores 25500 MHz max turbo 3 active cores 25500 MHz max turbo 2 active cores 25500 MHz max turbo 1 active cores 

You can disable the Turbo Boost using the BIOS or some Linux options/commands. The kernel support can be enabled/disabled using the /sys/devices/system/cpu/cpufreq/boost file.

Источник

How Do I Find CPU Frequency in Linux?

The Central Processing Unit (CPU) is considered an essential component in any system. It is also referred the “Computer’s Brain” because it handles all kinds of data processing operations. CPU is embedded in any system based on various specifications; frequency is one of them. The CPU frequency is also known as Clock speed or Clock rate. The clock speed of your CPU figures out how quickly it can process instructions per second. It is a unit of measurement for the number of your CPU execution, expressed in MHz or GHz.

Читайте также:  Ftp для сервера линукс

But have you ever thought of knowing what kind of CPU your computer has and how fast it runs? There exist many reasons why you would want to know what CPU you have in your system. Perhaps you are troubleshooting any hardware issue or loading a kernel module. Whatever the cause is, determining the CPU speed and type from the command line is quite easy in Linux. Several commands can be utilized for obtaining information about your processor, including CPU frequency. In this article, we have compiled some of those commands to get to know your CPU better.

Dmseg command

Dmseg is used for showing messages from the ring buffer of the kernel. In the following example, we have combined the Dmseg command with grep for filtering out the CPU speed from other related information.

lscpu command

lscpu command helps you to know about your CPU architecture. Lscpu pre-exists in the util-Linux package. Write out the below-given command in your terminal.

In the output, check out the “CPU MHz.”

i7z command

i7z is an exclusive tool for retrieving the processor states in Intel-based CPUs such as i3, i5, and i7.

Executing this command will provide you the following information:

Retrieving CPU speed from “/proc/cpuinfo” file

The “/proc/cpuinfo” file has all content related to the individual CPU cores. Now we will utilize the ‘grep’ and ‘cat’ command to only extract the information about the CPU speed from this file.

Instead of using “grep,” you can also use the “less” command for the same execution purpose.

hwinfo command

In the terminal, the detailed information about each hardware device can be printed using “hwinfo.” We will specify the “–cpu” parameter in the “hwinfo” command for displaying only the CPU speed.

inxi script

inxi is a powerful Linux script that permits you to print out the system’s hardware details. Execute the inxi command in your terminal with the “-C” option for displaying the processor-related information.

Conclusion:

As a result of efficient technology, we have developed a need for speed everywhere we go. CPU and its frequency or clock speed are the most widely associated characteristics with the high-performance of any computer. This post looks at how to get CPU speed details using various commands in Linux.

About the author

Talha Saif Malik

Talha is a contributor at Linux Hint with a vision to bring value and do useful things for the world. He loves to read, write and speak about Linux, Data, Computers and Technology.

Источник

Оцените статью
Adblock
detector