1/* 2 * Copyright (C) 2013 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.runner; 18 19import com.google.caliper.runner.Running.AfterExperimentMethods; 20import com.google.caliper.runner.Running.BeforeExperimentMethods; 21import com.google.common.collect.ImmutableSet; 22import dagger.Module; 23import dagger.Provides; 24 25import java.lang.reflect.Method; 26import javax.inject.Singleton; 27 28/** 29 * Binds objects related to a benchmark class. 30 */ 31// TODO(gak): move more of benchmark class into this module 32@Module 33public final class BenchmarkClassModule { 34 35 @Provides 36 @Singleton 37 static BenchmarkClass provideBenchmarkClass(@Running.BenchmarkClass Class<?> benchmarkClassObject) 38 throws InvalidBenchmarkException { 39 return BenchmarkClass.forClass(benchmarkClassObject); 40 } 41 42 @Provides 43 @BeforeExperimentMethods 44 static ImmutableSet<Method> provideBeforeExperimentMethods( 45 BenchmarkClass benchmarkClass) { 46 return benchmarkClass.beforeExperimentMethods(); 47 } 48 49 @Provides 50 @AfterExperimentMethods 51 static ImmutableSet<Method> provideAfterExperimentMethods( 52 BenchmarkClass benchmarkClass) { 53 return benchmarkClass.afterExperimentMethods(); 54 } 55} 56