Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Martin Gregorie Newsgroups: comp.lang.java.programmer Subject: Re: Logging database statement duration in a DRY way Date: Fri, 19 Aug 2016 16:05:57 -0000 (UTC) Organization: A noiseless patient Spider Lines: 17 Message-ID: References: <87wpjdhrbm.fsf@Equus.decebal.nl> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Fri, 19 Aug 2016 16:05:57 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="e5160e2be48f1ea550cf61512446f525"; logging-data="29517"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX199R7cO3H/Ezc25h/kf0/ifO9vFcHDeTug=" User-Agent: Pan/0.140 (Chocolate Salty Balls; GIT 3663720 git://git.gnome.org/pan2) Cancel-Lock: sha1:QZ5t9V9WLPi+4iIMysxnfqSrRos= Xref: csiph.com comp.lang.java.programmer:35413 On Fri, 19 Aug 2016 14:32:45 +0200, Cecil Westerhof wrote: > I like to log the time it takes for certain database actions. You could write a StopWatch class with start() and stop() methods: start() would grab the current time and stop() would return the amount of time since start() was called as milliseconds or nanoseconds. Different instances can be used to time various parts of an application. It would be trivial to put it under the control of a multi-level debug class or classes so that timing measurements are only made at appropriate debug levels. -- martin@ | Martin Gregorie gregorie. | Essex, UK org |