1/*
2 * Copyright (C) 2009 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 java.lang.annotation.ElementType;
20import java.lang.annotation.Retention;
21import java.lang.annotation.RetentionPolicy;
22import java.lang.annotation.Target;
23
24/**
25 * To make your benchmark depend on a parameterized value, create a field with the name you want
26 * this parameter to be known by, and add this annotation. Caliper will inject a value for this
27 * field to each instance it creates. These values come from
28 *
29 * <ul>
30 * <li>The command line, if specified using {@code -Dname=value1,value2,value3}
31 * <li>Otherwise, the {@link #value()} list given in the annotation
32 * <li>Otherwise, if the parameter type is either {@code boolean} or an {@code enum} type, Caliper
33 *     assumes you want all possible values.
34 * <li>Finally, if none of the above match, Caliper will display an error and exit.
35 * </ul>
36 *
37 * <p>Caliper parameters are always strings, but can be converted to other types at the point of
38 * injection. If the type of the field this annotation is applied to is not {@link String}, then the
39 * type class must contain a static {@code fromString(String)}, {@code decode(String)} or {@code
40 * valueOf(String)} method that returns that type, or a constructor accepting only a {@code String}.
41 *
42 * <p>Caliper will test every possible combination of parameter values for your benchmark. For
43 * example, if you have two parameters, {@code -Dletter=a,b,c -Dnumber=1,2}, Caliper will construct
44 * six independent "scenarios" and perform measurement for each one.
45 */
46@Retention(RetentionPolicy.RUNTIME)
47@Target(ElementType.FIELD)
48public @interface Param {
49  /**
50   * One or more default values, as strings, that this parameter should be given if none are
51   * specified on the command line. If values are specified on the command line, the defaults given
52   * here are all ignored.
53   */
54  String[] value() default {};
55}
56