1/*2 * Licensed to the Apache Software Foundation (ASF) under one3 * or more contributor license agreements. See the NOTICE file4 * distributed with this work for additional information5 * regarding copyright ownership. The ASF licenses this file6 * to you under the Apache License, Version 2.0 (the7 * "License"); you may not use this file except in compliance8 * with the License. You may obtain a copy of the License at9 *10 * http://www.apache.org/licenses/LICENSE-2.011 *12 * Unless required by applicable law or agreed to in writing, software13 * distributed under the License is distributed on an "AS IS" BASIS,14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.15 * See the License for the specific language governing permissions and16 * limitations under the License.17 */1819package com.yammer.metrics.core;
2021import com.yammer.metrics.stats.Snapshot;
2223import java.util.concurrent.Callable;
24import java.util.concurrent.TimeUnit;
2526/**27 * An empty Metrics' Timer implementation that does nothing.28 */29publicclassNoOpTimerextends Timer {
30/** singleton instance for everyone to use */31publicstaticfinalNoOpTimer INSTANCE = newNoOpTimer();
3233/** do not instantiate */34privateNoOpTimer() {
35super(newNoOpExecutorService(), TimeUnit.SECONDS, TimeUnit.SECONDS);
36 }
3738 @Override
39publicvoid clear() { }
4041 @Override
42publicvoid update(long duration, TimeUnit unit) { }
4344 @Override
45public <T> T time(Callable<T> event) throws Exception { return event.call(); }
4647 @Override
48publiclong count() { return 0; }
4950 @Override
51publicdouble fifteenMinuteRate() { return 0.0; }
5253 @Override
54publicdouble fiveMinuteRate() { return 0.0; }
5556 @Override
57publicdouble meanRate() { return 0.0; }
5859 @Override
60publicdouble oneMinuteRate() { return 0.0; }
6162 @Override
63publicdouble max() { return 0.0; }
6465 @Override
66publicdouble min() { return 0.0; }
6768 @Override
69publicdouble mean() { return 0.0; }
7071 @Override
72publicdouble stdDev() { return 0.0; }
7374 @Override
75publicdouble sum() { return 0.0; }
7677 @Override
78public Snapshot getSnapshot() { returnnew Snapshot(newdouble[0]); }
7980 @Override
81public String eventType() { return""; }
8283 @Override
84publicvoid stop() { }
8586 @Override
87public <T> void processWith(MetricProcessor<T> processor, MetricName name,
88 T context)
89throws Exception { }
90 }