Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Martin Gregorie Newsgroups: comp.lang.java.programmer Subject: Re: Get real, user and system time Date: Sat, 18 Jul 2020 20:59:31 -0000 (UTC) Organization: A noiseless patient Spider Lines: 21 Message-ID: References: <87o8oc99wk.fsf@munus.decebal.nl> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Sat, 18 Jul 2020 20:59:31 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="b04eacddc4358a12a58cbc27c30bd72a"; logging-data="1061"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1++DmZUjGWhO9/0G+dXP08ch8cZBQ5ekRM=" User-Agent: Pan/0.146 (Hic habitat felicitas; 8107378 git@gitlab.gnome.org:GNOME/pan.git) Cancel-Lock: sha1:cC3czv1NCWaGrLwpbEFCUHY2B6I= Xref: csiph.com comp.lang.java.programmer:39571 On Sat, 18 Jul 2020 16:26:35 +0200, Cecil Westerhof wrote: > In Linux we have the time command to get the real, user and system time > that a command takes. > I know how to get the real time a method takes, but is there a way to > get the user and system time a method takes also? > The only way I can think of, offhand would be the Stopwatch class, which appeared here some time ago. I won't include it as the (reasonably well- commented) copy I have is 118 lines. It has start(), stop() methods, so start/stop should be called to time a process and toString() to display the elapsed time in seconds. Its resolution is to the nearest millisecond. I've not included it because my copy is 118 lines, tolerably commented. I can e-mail you a copy if it looks useful. -- Martin | martin at Gregorie | gregorie dot org