本文整理匯總了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);
}