MIPS和MHz的区别

本文探讨了MIPS(每秒百万条指令)和MHz(兆赫)作为衡量CPU性能的指标,以及DMIPS(DhrystoneMIPS)的引入,强调了它们在不同架构和编译优化下的差异。文章还提及了Cortex-M3和Cortex-M4的DMIPS/MHz比率,以及Dhrystone作为基准测试的局限性和优点。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

MIPS vs MHz

MHz(兆赫)是每秒的时钟周期数。这通常由电路板上的晶体振荡器决定。例如,如果处理器或内存的运行频率为 20MHz,那么每秒就有 2 千万个时钟周期。它如何利用这些时钟周期完全取决于芯片。

有些处理器每个时钟脉冲执行一条指令。有些处理器则需要几个时钟脉冲来执行某些(或所有)指令。例如,简单的 x51 型处理器在 12 个时钟周期内执行一条简单指令。他们称这 12 个时钟周期为一个机器周期。较新的变种处理器每个机器周期可能只需要 4 个时钟周期,因此在相同的时钟频率下运行速度快 3 倍(执行的指令多 3 倍)。

这就是 MIPS 的由来。MIPS 是指每秒百万条指令。也就是说,实际执行的指令数量--它可能与上述时钟频率不同。

例如,如果一个老式 x51 CPU 的时钟频率为 24MHz,每个机器周期需要 12 个时钟周期,那么它可以执行 2 MIPS(24MHz/12 个周期)。即便如此,某些指令的执行时间可能超过一个机器周期,因此实际程序的运行速度可能低于这个数值。如果使用更现代版本的内核,每个机器周期使用 4 个时钟周期,那么处理指令的速度将达到 6 MIPS(24/4)--在相同时钟频率下快 3 倍。

如果比较类似类型的 CPU,MIPS 比 MHz 能提供更有意义的速度比较。

MHz (Megahertz) is the number of clock cycles every second. This is usually determined by a crystal oscillator on the board somewhere. For instance, if your processor or memory runs at 20MHz, it gets 20 million clock cycles every second. What it does with this depends entirely on the chip.

Some processors will perform one instruction for every clock pulse. Some will take several clock pulses for some (or all) instructions. For instance, the simple x51-type processors perform one simple instruction in 12 clock cycles. They call these 12 clock cycles one machine cycle. More recent varients may only take 4 clock cycles for each machine cycle, thus running 3 times faster (doing 3 times more instructions) on the same clock frequency.

This is where MIPS comes in. MIPS is Millions of Instructions Per Second. That is, how many actual instructions are performed - it may be different from the clock frequency as described above.

For instance, if an old x51 cpu has a clock of 24MHz, and takes 12 clock cycles per machine cycle, it can do 2 MIPS (24MHz/12 cycles). Even then, some instructions may take more than one machine cycle to perform so an actual program may run at less than this. If a more modern version of the core is used, that uses 4 clock cycles per machine cycle, it will process instructions at a rate of 6 MIPS (24/4) - 3 times faster for the same clock.

If comparing similar types of cpu, MIPS gives a more meaningful comparison of speed than MHz.

DMIPS

DMIPS 数字由 ARM 公布,几乎所有供应商都使用它们。

根据编译器的优化,有三种 DMIPS 数值。

DMIPS/MHz 是指每 1MHz 时钟频率下的 DMIPS。

关于 Cortex-M3,它们分别是 1.25/1.50/1.89 DMIPS/MHz。

关于 Cortex-M4,它们分别是 1.25/1.52/1.91 DMIPS/MHz(不含 FPU)和 1.27/1.55/1.95 DMIPS/MHz(含 FPU)。

我不知道为什么有 FPU 时数字会增加。

DMIPS 是 Dhrystone MIPS 的缩写,它是根据 VAX-11 的相对性能来衡量的。

Dhrystone 基准测试的是整数性能。

从 DIMIPS/MHz 的角度来看,Cortex-M3 等同于 Cortex-M4,因为除了 FPU 之外,两者的实现是相同的。

因此,时钟频率越高,性能越好。

无论如何,DMIPS 数值指的是最好的运行情况,并不总能在实际设备上重现。

简单地说,Cortex-M4 在 100MHz 时的性能为 125DMIPS,比 Cortex-M3 的 100DIMIPS 好。

The DMIPS numbers are announced by ARM and almost all vendor use them.

There are three DMIPS numbers according to the compiler optimization.

DMIPS/MHz is the DMIPS per 1MHz clock frequency.

Regarding Cortex-M3, they are 1.25/1.50/1.89 DMIPS/MHz.

Regarding Cortex-M4, they are 1.25/1.52/1.91 DMIPS/MHz (without FPU) and 1.27/1.55/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

夜流冰

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值