Is there a way to measure performance without depending on the hardware, i.e. two entirely different computers get the same score for the same code?

I could probably run the program on a server or something, but something local feels more reliable.

  • vole@lemmy.world
    link
    fedilink
    English
    arrow-up
    2
    ·
    edit-2
    11 months ago

    perf and valgrind might be good places to start. Although, some programs aren’t going to have the exact same executed instruction count between runs, and it’s possible that executed instruction count can depend on the exact CPU that’s running. You can probably mitigate the latter by running valgrind and the program inside of QEMU.

  • FuzzChef@feddit.de
    link
    fedilink
    arrow-up
    0
    ·
    11 months ago

    Yes, you can consider the algorithmic complexity of your code, which is independent of any hardware.

    • Sekoia@lemmy.blahaj.zoneOP
      link
      fedilink
      arrow-up
      0
      ·
      11 months ago

      Sure, but that makes a lot of optimizations nonexistent (e.g. cloning the input on an O(n) algorithm is “free”)

      • damium@programming.dev
        link
        fedilink
        English
        arrow-up
        1
        ·
        11 months ago

        You don’t need to use big-O. You can calculate the full complexity in algebraic notation. It’s just a lot more work as you don’t get to discard terms.