This is an automated email from the ASF dual-hosted git repository. eolivelli pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/maven-metric.git
The following commit(s) were added to refs/heads/master by this push: new a5f7a5d add utility method a5f7a5d is described below commit a5f7a5d4f9493b84dfe3d1f4bfa83094b68ba782 Author: Enrico Olivelli <eolive...@apache.org> AuthorDate: Sun May 10 16:28:49 2020 +0200 add utility method --- .../apache/maven/metrics/util/MetricsUtils.java | 53 ++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/maven-metrics-api/src/main/java/org/apache/maven/metrics/util/MetricsUtils.java b/maven-metrics-api/src/main/java/org/apache/maven/metrics/util/MetricsUtils.java new file mode 100644 index 0000000..8ee663f --- /dev/null +++ b/maven-metrics-api/src/main/java/org/apache/maven/metrics/util/MetricsUtils.java @@ -0,0 +1,53 @@ +package org.apache.maven.metrics.util; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** + * General utility for Metrics + * + * @author eolivelli + */ +public abstract class MetricsUtils +{ + private MetricsUtils() + { + + } + + /** + * Sample current time in milliseconds + * @return current time in milliseconds + * @see #elapsedMillis(long) + */ + public static long now() + { + return System.currentTimeMillis(); + } + + /** + * Return the number of elapsed milliseconds since a given timestamp. + * @param start the timestamp, supposed to be sampled with {@link #now() } + * @return the time in milliseconds + */ + public static long elapsedMillis( long start ) + { + return now() - start; + } +}