0

Let's say I have two alternative implementations of an algorithm, or two strategies. I could of course benchmark them with e.g. jmh. But is there any information I could get by looking at the decompiled bytecode?

A very native example would be counting if_* instructions for complexity or aload_* instructions for memory consumption.

garci560
  • 2,993
  • 4
  • 25
  • 34
  • 1
    You seem to be talking about bytecode, not decompiled code. – Kayaman Dec 07 '17 at 11:49
  • For CC, what is the point? If you have the source code, measure its CC directly. If not, knowing the CC is not going to help you do anything about it. Indeed, at that point you need to be concerned with correctness rather ease of maintenance. (Maintenance is not your concern ....) – Stephen C Dec 07 '17 at 11:55
  • For performance, the answer is probably no. Not even algorithmic complexity. I would say that there is little if anything to be gained from analyzing the bytecode or the decompiled code. – Stephen C Dec 07 '17 at 11:57
  • 3
    You are confusing several terms. Cyclomatic complexity has nothing to do with the performance you would measure with jmh, the bytecode has nothing to do with “decompiled code”, and `aload_` instructions have nothing to do with memory consumption, not even remotely. And, of course, there is no relationship between memory consumption and Cyclomatic complexity… – Holger Dec 07 '17 at 15:47

1 Answers1

0

No, you can't get any results from bytecode. Javac doesn't optimize your code at all, it's almost the same your java code just in bytecode representation. JIT will change all your code after optimizations. You can't even say anything about the performance of your code if you look at compiled asm code. The one way to measure it - run it.