blob: 93002e60ae044b3a0a6b01aaa671479b74fa27d7 [file] [log] [blame]
Paul Duffin7fc0b452015-11-10 17:45:15 +00001/*
2 * Copyright (C) 2010 Google Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.google.caliper;
18
19import com.google.common.base.Supplier;
20
21import java.io.PrintStream;
22
23abstract class Measurer {
24
25 private PrintStream logStream = System.out;
26
27 /**
28 * Sets the stream used to log caliper events.
29 */
30 void setLogStream(PrintStream logStream) {
31 this.logStream = logStream;
32 }
33
34 public abstract MeasurementSet run(Supplier<ConfiguredBenchmark> testSupplier) throws Exception;
35
36 protected void prepareForTest() {
37 System.gc();
38 System.gc();
39 }
40
41 protected final void log(String message) {
42 logStream.println(LogConstants.CALIPER_LOG_PREFIX + message);
43 }
44}