19.1. Using the lightweight metrics tool

Before we get into what are and what aren’t lightweight metrics, let’s discuss the promise this tool hopes to provide. When developing an application, it’s often valuable to know how long an operation took to perform. This allows you to optimize a routine within the application and get hard data on how much better (or worse) it performs after the change.

Measuring the time it takes to execute an operation isn’t that difficult. You could hardcode a few debug statements to print out timings to the dev-mode console or to some TextArea on the page. Something like the following would work in most cases:

GWT.log("start: " + Duration.currentTimeMillis()); someExpensiveOperation(); GWT.log("end: " + Duration.currentTimeMillis()); ...

Get GWT in Action, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.