hrtimer
| resources: | Home Mailing List Installation Source Code Members Bugs Screenshots |
|---|
|
hrtimer is a project that includes hrprofiler, a new profiler for Javascript in Mozilla, hrcov, a tool for Javascript code coverage, and hrtimer proper, a facility for script to directly access various system timers and metrics. hrcov | hrprofiler | hrtimer hrcovhrcov is a simple code coverage tool for Javascript. It will list all scripts Firefox knows about, and the lines of which that were not executed in a given time period. No other similar tool exists for Javascript currently. As of January 2008, the only tools available are a Firebug plugin that only gives function coverage, and a preprocessor. hrcov is the only Javascript code coverage tool that provides line-by-line coverage information. The main use case for hrcov is unit testing: we want to be able to ensure that a unit test covers all aspects of a given piece of functionality. Like all hrtimer tools, hrcov works equally well with content and chrome code. outlinehrcov can divide a source file into chunks and report on the coverage of each chunk separately. It divides files the same way Emacs' outline-mode does, and understands the same format of file variables. For example, look at ffhrcov_result.js. At the end of the file, we have:
// Local Variables:
// outline-regexp: "// ==+\\s-+"
// End:
This block means that consecutive sections of the file are separated by lines beginning with "// ==", a variable number of '=' signs, and more space. hrcov will automatically figure out file sectioning based on these lines and display the results as a tree in the coverage report. hrprofilerhrprofiler is a new profiler for content and chrome Javascript. Unlike Venkman and the Firebug profiler, hrprofiler will:
hrtimer API
The hrtimer API is exposed to all scripts (even unprivileged
ones running on the web) via a Get an
// The {} is a dummy argument required by xpconnect
var available_timers = hrtimer.getAvailableTimers({});
Each entry in the array is a string, the name of a timer. To get corresponding timer object, simply call:
var my_timer = hrtimer.getTimer(name_of_timer)
Timer objects are documented in the linked-to IDL file above. Simply put, get the current value of the timer by calling:
var time_in_ns = my_timer.getTime()
Timers for POSIX systems (including OS X)
Timers for Windows
|
What's New
|