# QEMU performance for U54-mc

**URL:** <https://forums.sifive.com/t/qemu-performance-for-u54-mc/4210>\
**Category:** HiFive Unleashed\
**Created:** [November 15, 2020, 10:28pm UTC](https://forums.sifive.com/t/qemu-performance-for-u54-mc/4210 "2020-11-15T22:28:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![JMG](https://avatars.discourse-cdn.com/v4/letter/j/e68b1a/32.png) [@JMG](https://forums.sifive.com/u/JMG)\
**Post date:** [November 15, 2020, 10:28pm UTC](https://forums.sifive.com/t/qemu-performance-for-u54-mc/4210/1 "2020-11-15T22:28:16Z")

</div>

Hi

I’m trying to figure out how can I measure a function’s performance using QEMU, since for what i’ve heard it’s not very cycle-accurate.

Right now I’m leaving one of the u54-mc’s harts running on a while loop as some sort of makeshift timer, but that is giving me weird results.  
If i leave a single hart to execute the whole function by itself I get that it measures twice as much time to run than if I split the function between two harts but leave the second one waiting for the first to finish it´s part.

So I want to know what could be causing this difference, if it could be some QEMU or freedomstudio setting, or perhaps something else. Any help is appreciated.

---

<div class="post-metadata">

**Author:** ![bruce](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.sifive.com/bruce/32/452_2.png) [@bruce](https://forums.sifive.com/u/bruce)\
**Post date:** [November 16, 2020, 2:06am UTC](https://forums.sifive.com/t/qemu-performance-for-u54-mc/4210/2 "2020-11-16T02:06:22Z")

</div>

QEMU is in no way intended to produce cycle-accurate or even speed representative results. QEMU’s purpose is to emulate RISC-V code as quickly as possible (at least in a way that allows QEMU to be portable to different host systems and the compromises that involves).

QEMU has no knowledge of any particular RISC-V CPU core or its performance characteristics. It has functional emulation of various sets of peripherals that might be found on particular boards, but that’s a different matter.

If you want cycle-accurate simulation then you need to do one of:

- run the RTL for the system in a simulator such as verilator (and a few tens of kHz effective speed)
- run the RTL for the system in an FPGA (at 30 to 100 MHz)

or

- create a pipeline model of the system for a simulator such as gem5 [https://www.gem5.org/](https://www.gem5.org/)

or

- run on actual U54-mc hardware such as the HiFive Unleashed or Icicle.

---

<div class="post-metadata">

**Author:** ![JMG](https://avatars.discourse-cdn.com/v4/letter/j/e68b1a/32.png) [@JMG](https://forums.sifive.com/u/JMG)\
**Post date:** [November 16, 2020, 5:12pm UTC](https://forums.sifive.com/t/qemu-performance-for-u54-mc/4210/3 "2020-11-16T17:12:35Z")

</div>

Thanks for the clarification, I’ll try that
