001/* 002 * (C) Copyright 2013 Nuxeo SA (http://nuxeo.com/) and contributors. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the GNU Lesser General Public License 006 * (LGPL) version 2.1 which accompanies this distribution, and is available at 007 * http://www.gnu.org/licenses/lgpl-2.1.html 008 * 009 * This library is distributed in the hope that it will be useful, 010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 012 * Lesser General Public License for more details. 013 * 014 * Contributors: 015 * Martin Pernollet 016 */ 017 018package org.nuxeo.ecm.platform.groups.audit.service.acl.data; 019 020public class TicToc { 021 public TicToc() { 022 start = 0; 023 stop = 0; 024 } 025 026 public void tic() { 027 start = System.nanoTime(); 028 } 029 030 /** return time in second */ 031 public double toc() { 032 stop = System.nanoTime(); 033 return elapsedSecond(); 034 } 035 036 public long rawToc() { 037 stop = System.nanoTime(); 038 return stop; 039 } 040 041 public long elapsedNanosecond() { 042 return stop - start; 043 } 044 045 public double elapsedMicrosecond() { 046 return elapsedNanosecond() / 1000; 047 } 048 049 public double elapsedMilisecond() { 050 return elapsedMicrosecond() / 1000; 051 } 052 053 public double elapsedSecond() { 054 return elapsedMilisecond() / 1000; 055 } 056 057 public long getStart() { 058 return start; 059 } 060 061 public long getStop() { 062 return stop; 063 } 064 065 protected long start; 066 067 protected long stop; 068}