0

When looking at intermediate language, each instruction has a particular byte size.

If I have a method with a total code size (the sum of instructions sizes) of 10 bytes and a method with a total code size of 20 bytes, can I presume that the first one executes faster?

I have no knowledge on how the IL is converted into machine code and thus I would think that the performance is different based on the IL instruction itself and not directly related to its byte size.

Is the execution time of IL directly related to its code size?

Jaanus Varus
  • 3,508
  • 3
  • 31
  • 49

1 Answers1

4

Is the execution time of IL directly related to its code size?

No. Naively, it seems like this should be true, but it's far more complicated than that in reality.

It varies depending on the individual case. This is why it's impossible to give "rules" for optimizing code. You can't make naive assumptions about what will be faster. You just have to test the various options on your target architecture and see which one is actually faster.

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574