Calculating exact runtime, not actual runtime

cectavafeve

New Member
Is is possible to create a program that, say with byte code, runs your program as normal, keeping a tally of the total run-time by using defined run-times of each instruction as you go? Then, once your program finished, you'd have an exact, system independent value for the run-time, without the need of running your program over and over and averaging the results, or finding the min. Sure the relation between this and actual run-time differs depending on excessive quantities of variables, but it still seems like such a figure would be nice to at least have the option to use.So, for clarity, there's four questions here (sorry, but this just prevents follow up questions for conciseness), building on each other:1: Is it possible, or is there a theoretical result that prevents this (halting problem or something)?
  • Yes (via Asav) just make an interpreter for the language (say, Bytecode) and run the program as described. Cool, thanks.
2: If it is possible, why is this never used? It seems valuable for many practical reasons.
  • (via Dave) Often it's nice to have exact run-times, and usually that's all that you need (if you need more specific results, you probably should to start doing system dependent optimization where this isn't applicable). Still though, if anything a program like this would give you just as valuable relative results, and most importantly less noise for the same code. Isn't that better? Why doesn't the (seemingly simple to implement option) even exist?
3: Or is there one that exists and I am just missing it?
  • (via Asav) There is the Proccess class in the .net Framework does this pretty well (TotalProcessorTime and UserProcessorTime). This seems nice, and it partially answers my question, but still, is there a system independent version? Or even a Java equivalent?
Thanks!
 
Back
Top