當前位置: 首頁>>代碼示例>>Java>>正文


Java State類代碼示例

本文整理匯總了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;
  // }
}
 
開發者ID:msteindorfer,項目名稱:criterion,代碼行數:27,代碼來源:BitmapIndexingBenchmark.java

示例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);
                }
            }
        }
    }
}
 
開發者ID:msteindorfer,項目名稱:jmh,代碼行數:28,代碼來源:StateObjectHandler.java

示例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);
    }
}
 
開發者ID:msteindorfer,項目名稱:jmh,代碼行數:25,代碼來源:StateObjectHandler.java

示例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;
}
 
開發者ID:msteindorfer,項目名稱:jmh,代碼行數:8,代碼來源:StateObjectHandler.java

示例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);
}
 
開發者ID:msteindorfer,項目名稱:jmh,代碼行數:11,代碼來源:StateObjectHandler.java

示例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
    );
}
 
開發者ID:Graylog2,項目名稱:graylog-plugin-pipeline-processor,代碼行數:60,代碼來源:FilterchainVsPipeline.java

示例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
                );
            }
        }
    }
}
 
開發者ID:msteindorfer,項目名稱:jmh,代碼行數:43,代碼來源:StateObjectHandler.java

示例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);
}
 
開發者ID:apache,項目名稱:logging-log4j2,代碼行數:7,代碼來源:AnnotationVsMarkerInterface.java


注:本文中的org.openjdk.jmh.annotations.State類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。