On 21Feb2014 18:37, Liam Marsh <liam.marsh.home@gmail.com> wrote:
is it possible to create(or tell me its name) a command to evaluate compute length of a command/procedure? (in number of: -processor operations(for 32 and 64 bit processors) -RAM read and write operations -hard disk write and read operations -eventual graphic operations ) this may be difficult, but it ables users to optimise their programs.
By inspection of the code, without running the procedure? In general, probably not; I think that's equivalent to the halting problem and that is known to not have a universal solution. I think your question needs refining. Please provide more context. A skillful human can look at a function and, often, evaluate its performance in terms of its input. Not always, it depends on the inputs, and it also depends on what aspects of the operations are themselves expensive. Not all functions will terminate for all inputs, either (back to the halting problem again), so how expensive will you call such a function? Even supposing you have a suitable function (one you can inspect and decide on how it will behave), your choices of measurement are all a little vague and variable: For each of your 4 items above, they are highly dependent on the system architecture: different processors have different instruction sets, different compilers have different optimisation possibilities (and those possibilities depend on the specific CPU, too), RAM read and write operations depend on both the CPU and the memory architecture, hard disk write and read operations depend on both the language I/O library support and the OS buffering systems, and the cost of a "hard disk write and read operation" depends also on the hard disc hardware (SSD? on-disc buffering? RAID? ...) and graphics operations are also very variable. Yes, a human can often look at a human-written function and give an opinion about its cost. Cheers, -- Cameron Simpson <cs@zip.com.au> Say it with flowers - Give her a triffid. - Russell Sparkes, russell@cerberus.bhpese.oz.au