本文整理汇总了Java中org.openjdk.jmh.annotations.State类的典型用法代码示例。如果您正苦于以下问题:Java State类的具体用法?Java State怎么用?Java State使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
State类属于org.openjdk.jmh.annotations包,在下文中一共展示了State类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toState
import org.openjdk.jmh.annotations.State; //导入依赖的package包/类
State toState(long bitmap, int doubledMask) {
final long pattern = ((bitmap >>> doubledMask) & 0b11);
if (pattern == 0b00L) {
return State.EMPTY;
} else if (pattern == 0b01L) {
return State.PAYLOAD;
} else if (pattern == 0b10L) {
return State.NODE;
} else {
return State.PAYLOAD_RARE;
}
// final int pattern = (int) ((bitmap >>> doubledMask) & 0b11);
//
// switch (pattern) {
// case 0b01:
// return State.PAYLOAD;
// case 0b10:
// return State.NODE;
// case 0b11:
// return State.PAYLOAD_RARE;
// default:
// return State.EMPTY;
// }
}
示例2: recursiveStateResolve
import org.openjdk.jmh.annotations.State; //导入依赖的package包/类
/**
* Recursively resolve if there are any other states referenced through helper methods.
*/
private void recursiveStateResolve(MethodInfo method, ClassInfo pci, StateObject pso, Set<StateObject> seen) {
for (MethodInfo mi : BenchmarkGeneratorUtils.getMethods(pci)) {
if (mi.getAnnotation(Setup.class) != null || mi.getAnnotation(TearDown.class) != null) {
for (ParameterInfo pi : mi.getParameters()) {
ClassInfo ci = pi.getType();
StateObject so = new StateObject(identifiers, ci, getState(ci, pi).value());
if (!seen.add(so)) {
throw new GenerationException("@" + State.class.getSimpleName() + " dependency cycle is detected.", pi);
}
if (!stateHelperArgs.get(mi.getQualifiedName()).contains(so)) {
stateObjects.add(so);
stateObjectDeps.put(pso, so);
stateHelperArgs.put(mi.getQualifiedName(), so);
bindState(method, so, ci);
recursiveStateResolve(method, ci, so, seen);
}
}
}
}
}
示例3: checkHelpers
import org.openjdk.jmh.annotations.State; //导入依赖的package包/类
private void checkHelpers(MethodInfo mi, Class<? extends Annotation> annClass) {
// OK to have these annotation for @State objects
if (BenchmarkGeneratorUtils.getAnnSuper(mi.getDeclaringClass(), State.class) == null) {
if (!mi.getDeclaringClass().isAbstract()) {
throw new GenerationException(
"@" + TearDown.class.getSimpleName() + " annotation is placed within " +
"the class not having @" + State.class.getSimpleName() + " annotation. " +
"This has no behavioral effect, and prohibited.",
mi);
}
}
if (!mi.isPublic()) {
throw new GenerationException(
"@" + annClass.getSimpleName() + " method should be public.",
mi);
}
if (!mi.getReturnType().equalsIgnoreCase("void")) {
throw new GenerationException(
"@" + annClass.getSimpleName() + " method should not return anything.",
mi);
}
}
示例4: getState
import org.openjdk.jmh.annotations.State; //导入依赖的package包/类
public State getState(ClassInfo ci, ParameterInfo pi) {
State ann = BenchmarkGeneratorUtils.getAnnSuper(ci, State.class);
if (ann == null) {
throw new GenerationException("The method parameter is not a @" + State.class.getSimpleName() + ": ", pi);
}
return ann;
}
示例5: bindImplicit
import org.openjdk.jmh.annotations.State; //导入依赖的package包/类
public void bindImplicit(ClassInfo ci, String label, Scope scope) {
State ann = BenchmarkGeneratorUtils.getAnnSuper(ci, State.class);
StateObject so = new StateObject(identifiers, ci, (ann != null) ? ann.value() : scope);
stateObjects.add(so);
implicits.put(label, so);
bindState(null, so, ci);
Set<StateObject> seen = new HashSet<StateObject>();
recursiveStateResolve(null, ci, so, seen);
}
示例6: InterpreterState
import org.openjdk.jmh.annotations.State; //导入依赖的package包/类
public InterpreterState() {
final RuleService ruleService = mock(MongoDbRuleService.class);
when(ruleService.loadAll()).thenReturn(Collections.singleton(
RuleDao.create("abc",
"title",
"description",
"rule \"add\"\n" +
"when tostring($message.message) == \"original message\"\n" +
"then\n" +
" set_field(\"field\", \"derived message\");\n" +
"end",
Tools.nowUTC(),
null)
));
final PipelineService pipelineService = mock(MongoDbPipelineService.class);
when(pipelineService.loadAll()).thenReturn(Collections.singleton(
PipelineDao.create("cde", "title", "description",
"pipeline \"pipeline\"\n" +
"stage 0 match all\n" +
" rule \"add\";\n" +
"end\n",
Tools.nowUTC(),
null)
));
final PipelineStreamConnectionsService pipelineStreamConnectionsService = mock(MongoDbPipelineStreamConnectionsService.class);
final PipelineConnections pipelineStreamConnection = PipelineConnections.create(null,
"default",
newHashSet("cde"));
when(pipelineStreamConnectionsService.loadAll()).thenReturn(
newHashSet(pipelineStreamConnection)
);
final Map<String, Function<?>> functions = Maps.newHashMap();
functions.put(SetField.NAME, new SetField());
functions.put(StringConversion.NAME, new StringConversion());
final FunctionRegistry functionRegistry = new FunctionRegistry(functions);
final PipelineRuleParser parser = new PipelineRuleParser(functionRegistry, new CodeGenerator(JavaCompiler::new));
final MetricRegistry metricRegistry = new MetricRegistry();
final ConfigurationStateUpdater stateUpdater = new ConfigurationStateUpdater(ruleService,
pipelineService,
pipelineStreamConnectionsService,
parser,
new MetricRegistry(),
functionRegistry,
Executors.newScheduledThreadPool(1),
mock(EventBus.class),
(currentPipelines, streamPipelineConnections, classLoader) -> new PipelineInterpreter.State(currentPipelines, streamPipelineConnections, null, metricRegistry, 1, true),
false);
interpreter = new PipelineInterpreter(
mock(Journal.class),
metricRegistry,
mock(EventBus.class),
stateUpdater
);
}
示例7: checkParam
import org.openjdk.jmh.annotations.State; //导入依赖的package包/类
private void checkParam(FieldInfo fi) {
if (fi.isStatic()) {
throw new GenerationException(
"@" + Param.class.getSimpleName() + " annotation is not acceptable on static fields.",
fi);
}
if (BenchmarkGeneratorUtils.getAnnSyntax(fi.getDeclaringClass(), State.class) == null) {
throw new GenerationException(
"@" + Param.class.getSimpleName() + " annotation should be placed in @" + State.class.getSimpleName() +
"-annotated class.", fi);
}
ClassInfo type = fi.getType();
if (!isParamTypeAcceptable(type)) {
throw new GenerationException(
"@" + Param.class.getSimpleName() + " can only be placed over the annotation-compatible types:" +
" primitives, primitive wrappers, Strings, or enums.", fi);
}
String[] values = fi.getAnnotation(Param.class).value();
if (values.length == 1 && values[0].equalsIgnoreCase(Param.BLANK_ARGS)) {
if (!fi.getType().isEnum()) {
throw new GenerationException(
"@" + Param.class.getSimpleName() + " should provide the default parameters.", fi);
} else {
// if type is enum then don't need to check conformity
}
} else {
for (String val : values) {
if (!isParamValueConforming(fi, val, type)) {
throw new GenerationException(
"Some @" + Param.class.getSimpleName() + " values can not be converted to target type: " +
"\"" + val + "\" can not be converted to " + type,
fi
);
}
}
}
}
示例8: annotationPresent
import org.openjdk.jmh.annotations.State; //导入依赖的package包/类
@Benchmark
@BenchmarkMode({Mode.Throughput, Mode.AverageTime, Mode.SampleTime, Mode.SingleShotTime})
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public Object annotationPresent() {
return this.getClass().isAnnotationPresent(State.class);
}