模块 ringo/profiler

用于测量 JavaScript 函数执行时间的分析器。请注意,您需要运行优化级别 -1 以使分析工作。在优化代码上运行分析器将不会产生任何数据。

Functions

Class Profiler

Instance Methods


Profiler ()

用于测量函数调用的频率和运行时间的类。


Profiler.prototype. formatResult (maxFrames)

Parameters

Number maxFrames

optional maximal number of frames to include


Profiler.prototype. getFrames ()


Profiler.prototype. getScriptFrame (cx, script)

Parameters

Object cx
Function script

Profiler.prototype. toString ()


profile (func, maxFrames)

分析函数调用的便捷函数。

Parameters

Function func

the function to profile

Number maxFrames

optional maximal number of frames to include

Returns

Object

an object with the following properties:

  • result: the value returned by the function, if any
  • error: the error thrown by the function, if any
  • profiler: the Profiler instance used to profile the invocation