getCalls()and
statistic()API.
Example usage:
def proxy = ProxyMetaClass.getInstance(ArrayList.class)
proxy.interceptor = new BenchmarkInterceptor()
proxy.use {
def list = (0..10000).collect{ it }
4.times { list.size() }
4000.times { list.set(it, it+1) }
}
proxy.interceptor.statistic()
Which produces the following output:
[[size, 4, 0], [set, 4000, 21]]
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public Object | Returns: resultreceiver object for the called method object, String name of the called method methodName, Object[] arguments to the called method arguments, Object result of the executed method call or result of beforeInvoke if method was not called result)Implements groovy. |
| public Object | Returns: null relays this result.receiver object for the method call object, String name of the method to call methodName, Object[] arguments to the method call arguments)Implements groovy. |
| public boolean | Returns: trueImplements groovy. |
| public Map | |
| public void | |
| public List | Returns: a list of lines, each item is [methodname, numberOfCalls, accumulatedTime]Returns benchmark statistics as a List<Object[]>. |
| calls | back to summary |
|---|---|
| protected Map<K, V> calls | |
| BenchmarkInterceptor | back to summary |
|---|---|
| public BenchmarkInterceptor() | |
| afterInvoke | back to summary |
|---|---|
| public Object afterInvoke(Object object, String methodName, Object[] arguments, Object result) Implements groovy. This code is executed after the method is called. | |
| beforeInvoke | back to summary |
|---|---|
| public Object beforeInvoke(Object object, String methodName, Object[] arguments) Implements groovy. This code is executed before the method is called. | |
| doInvoke | back to summary |
|---|---|
| public boolean doInvoke() Implements groovy. The call should be invoked separately
| |
| getCalls | back to summary |
|---|---|
| public Map Returns the raw data associated with the current benchmark run. | |
| reset | back to summary |
|---|---|
| public void reset() Resets all the benchmark data on this object. | |
| statistic | back to summary |
|---|---|
| public List Returns benchmark statistics as a List<Object[]>. AccumulateTime is measured in milliseconds and is as accurate as System.currentTimeMillis() allows it to be.
| |