001/* 002 * (C) Copyright 2013 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * Martin Pernollet 018 */ 019 020package org.nuxeo.ecm.platform.groups.audit.service.acl.data; 021 022public class TicToc { 023 public TicToc() { 024 start = 0; 025 stop = 0; 026 } 027 028 public void tic() { 029 start = System.nanoTime(); 030 } 031 032 /** return time in second */ 033 public double toc() { 034 stop = System.nanoTime(); 035 return elapsedSecond(); 036 } 037 038 public long rawToc() { 039 stop = System.nanoTime(); 040 return stop; 041 } 042 043 public long elapsedNanosecond() { 044 return stop - start; 045 } 046 047 public double elapsedMicrosecond() { 048 return elapsedNanosecond() / 1000; 049 } 050 051 public double elapsedMilisecond() { 052 return elapsedMicrosecond() / 1000; 053 } 054 055 public double elapsedSecond() { 056 return elapsedMilisecond() / 1000; 057 } 058 059 public long getStart() { 060 return start; 061 } 062 063 public long getStop() { 064 return stop; 065 } 066 067 protected long start; 068 069 protected long stop; 070}