Proposal for a small language change
Mark Thornton
mthornton at optrak.co.uk
Mon Apr 13 14:44:22 PDT 2009
Angelo Borsotti wrote:
> Author: Angelo Borsotti, former Senior Director Software Technology,
> Alcatel-Lucent Optics
>
> Overview
> Feature Summary: fast and accurate measurement of execution time
> Major Advantage: optimization of algorithms by measuring execution
> times of small snippets of code executed many times
> Major Benefit: greatly increases observability of programs
> Major Disadvantage: very little cost
> Alternatives: there are no alternatives
>
> Examples:
>
> Simple example:
> long c0 = System.cycles();
> i++;
> long c = System.cycles() - c0;
> Advanced example:
> long cycles = 0;
> for (int i = 0; i < bound; i++){
> ...
> long c0 = System.cycles();
> some statements
> cycles += System.cycles()- c0;
> }
>
>
As Joe has said the proposal period is over and this proposal doesn't
need a language change.
The existing System.nanoTime() method could be implemented using CPU
cycle counters. However there are significant problems on multi-core or
multi-processor systems and where power management is in use. Some
systems don't keep the cycle counters synchronized across CPUs, so if a
thread is migrated from one CPU to another the computed elapsed cycle
time is not reliable.
Some interesting information on timing can be found here:
http://blogs.sun.com/dholmes/entry/inside_the_hotspot_vm_clocks
Mark Thornton
More information about the coin-dev
mailing list