org.openjdk.jmh.infra.BenchmarkParams Java Examples

The following examples show how to use org.openjdk.jmh.infra.BenchmarkParams. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MemoryProfiler.java    From customized-symspell with MIT License 6 votes vote down vote up
@Override
public Collection<? extends Result> afterIteration(BenchmarkParams bp, IterationParams ip,
    IterationResult result) {
  MemoryUsage heapUsage = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage();
  MemoryUsage nonheapUsage = ManagementFactory.getMemoryMXBean().getNonHeapMemoryUsage();

  Collection<ScalarResult> results = new ArrayList<>();
  results.add(
      new ScalarResult(Defaults.PREFIX + "mem.heap", heapUsage.getUsed() / (1024 * 1024.0), "MB",
          AggregationPolicy.MAX));
  results.add(new ScalarResult(
      Defaults.PREFIX + "mem.nonheap", nonheapUsage.getUsed() / (1024 * 1024.0), "MB",
      AggregationPolicy.MAX));

  return results;
}
 
Example #2
Source File: PerfTestFairQueuingPacketScheduler.java    From arcusplatform with Apache License 2.0 6 votes vote down vote up
@Setup(Level.Trial)
public void setup(BenchmarkParams params) {
   clock = NetworkClocks.system();
   scheduler = PacketSchedulers.<Packet>fairQueuing()
      .blockOnQueueFull()
      //.useArrayQueue(qSize)
      //.useLinkedQueue(qSize)
      .useLinkedTransferQueue()
      .build();

   producers = new PacketScheduler.Producer[params.getThreads()][qPerThr];
   for (int p = 0; p < producers.length; ++p) {
      for (int q = 0; q < producers[p].length; ++q) {
         producers[p][q] = scheduler.attach();
      }
   }
}
 
Example #3
Source File: RocksDb.java    From benchmarks with Apache License 2.0 6 votes vote down vote up
@Override
@SuppressWarnings("PMD.CloseResource")
public void setup(final BenchmarkParams b) throws IOException {
  super.setup(b);
  wkb = new UnsafeBuffer(new byte[keySize]);
  wvb = new UnsafeBuffer(new byte[valSize]);
  loadLibrary();
  final Options options = new Options();
  options.setCreateIfMissing(true);
  options.setCompressionType(NO_COMPRESSION);
  try {
    db = open(options, tmp.getAbsolutePath());
  } catch (final RocksDBException ex) {
    throw new IOException(ex);
  }
}
 
Example #4
Source File: LmdbJni.java    From benchmarks with Apache License 2.0 6 votes vote down vote up
public void setup(final BenchmarkParams b, final boolean sync) throws
    IOException {
  super.setup(b);
  wkb = new DirectBuffer(allocateDirect(keySize));
  wvb = new DirectBuffer(allocateDirect(valSize));
  keyBytes = new byte[keySize];
  valBytes = new byte[valSize];

  final EnvFlags[] envFlags = envFlags(writeMap, sync);

  env = new Env();
  env.setMapSize(mapSize(num, valSize));
  env.setMaxDbs(1);
  env.setMaxReaders(2);
  env.open(tmp.getAbsolutePath(), mask(envFlags), POSIX_MODE);

  try (Transaction tx = env.createWriteTransaction()) {
    final DbiFlags[] flags = dbiFlags(intKey);
    db = env.openDatabase(tx, "db", mask(flags));
    tx.commit();
  }
}
 
Example #5
Source File: FlightRecorderProfiler.java    From calcite with Apache License 2.0 6 votes vote down vote up
@Override public Collection<String> addJVMOptions(BenchmarkParams params) {
  StringBuilder sb = new StringBuilder();
  for (String param : params.getParamsKeys()) {
    if (sb.length() != 0) {
      sb.append('-');
    }
    sb.append(param).append('-').append(params.getParam(param));
  }

  long duration =
      getDurationSeconds(params.getWarmup()) + getDurationSeconds(params.getMeasurement());
  return Arrays.asList(
      "-XX:+UnlockCommercialFeatures", "-XX:+FlightRecorder",
      "-XX:StartFlightRecording=settings=profile,duration=" + duration + "s,filename="
          + params.getBenchmark() + "_" + sb + ".jfr");
}
 
Example #6
Source File: Xodus.java    From benchmarks with Apache License 2.0 6 votes vote down vote up
@Override
public void setup(final BenchmarkParams b) throws IOException {
  super.setup(b);

  final EnvironmentConfig cfg = new EnvironmentConfig();
  // size of immutable .xd file is 32MB
  cfg.setLogFileSize(32 * 1_024);
  cfg.setLogCachePageSize(0x2_0000);
  env = newInstance(tmp, cfg);

  env.executeInTransaction((final Transaction txn) -> {
    // WITHOUT_DUPLICATES_WITH_PREFIXING means Patricia tree is used,
    // not B+Tree (WITHOUT_DUPLICATES)
    // Patricia tree gives faster random access, both for reading and writing
    store = env.openStore("without_dups", WITHOUT_DUPLICATES_WITH_PREFIXING,
                          txn);
  });
}
 
Example #7
Source File: Chronicle.java    From benchmarks with Apache License 2.0 6 votes vote down vote up
@Override
public void setup(final BenchmarkParams b) throws IOException {
  super.setup(b);
  wkb = new UnsafeBuffer(new byte[keySize]);
  wvb = new UnsafeBuffer(new byte[valSize]);

  try {
    map = of(byte[].class, byte[].class)
        .constantKeySizeBySample(new byte[keySize])
        .constantValueSizeBySample(new byte[valSize])
        .entries(num)
        .createPersistedTo(new File(tmp, "chroncile.map"));
  } catch (final IOException ex) {
    throw new IllegalStateException(ex);
  }
}
 
Example #8
Source File: MemoryProfiler.java    From unsafe with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public Collection<? extends Result> afterIteration(BenchmarkParams benchmarkParams,
    IterationParams iterationParams, IterationResult result) {
  final Runtime runtime = Runtime.getRuntime();

  final long max = runtime.maxMemory();
  final long total = runtime.totalMemory();
  final long free = runtime.freeMemory();
  final long used = total - free;

  return Arrays
      .asList(new ProfilerResult(PREFIX + "rt.mem.max", max, "bytes", AggregationPolicy.MAX),
          new ProfilerResult(PREFIX + "rt.mem.total", total, "bytes", AggregationPolicy.MAX),
          new ProfilerResult(PREFIX + "rt.mem.free", free, "bytes", AggregationPolicy.MAX),
          new ProfilerResult(PREFIX + "rt.mem.used", used, "bytes", AggregationPolicy.MAX));
}
 
Example #9
Source File: LmdbLwjgl.java    From benchmarks with Apache License 2.0 6 votes vote down vote up
@Setup(Trial)
@Override
public void setup(final BenchmarkParams b) throws IOException {
  super.setup(b, false);
  super.write();

  try (MemoryStack stack = stackPush()) {
    final PointerBuffer pp = stack.mallocPointer(1);

    E(mdb_txn_begin(env, NULL, MDB_RDONLY, pp));
    txn = pp.get(0);

    E(mdb_cursor_open(txn, db, pp));
    c = pp.get(0);
  }
}
 
Example #10
Source File: CommonLmdbJava.java    From benchmarks with Apache License 2.0 5 votes vote down vote up
public void setup(final BenchmarkParams b, final boolean sync) throws
    IOException {
  super.setup(b);
  final EnvFlags[] envFlags = envFlags(writeMap, sync);
  env = create(bufferProxy)
      .setMapSize(mapSize(num, valSize))
      .setMaxDbs(1)
      .setMaxReaders(2)
      .open(tmp, POSIX_MODE, envFlags);

  final DbiFlags[] flags = dbiFlags(intKey);
  db = env.openDbi("db", flags);
}
 
Example #11
Source File: BenchBase.java    From eagle with Apache License 2.0 5 votes vote down vote up
@Setup(Level.Trial)
public void setup(BenchmarkParams params) {
    switch (framework) {
        case "eagle":
            setupEagle();
            break;
        case "dubbo":
            setupDubbo();
            break;
    }
}
 
Example #12
Source File: Common.java    From benchmarks with Apache License 2.0 5 votes vote down vote up
private File create(final BenchmarkParams b, final String suffix) {
  final File f = new File(TMP_BENCH, b.id() + suffix);
  if (!f.mkdirs()) {
    throw new IllegalStateException("Cannot mkdir " + f);
  }
  return f;
}
 
Example #13
Source File: Common.java    From benchmarks with Apache License 2.0 5 votes vote down vote up
public void setup(final BenchmarkParams b) throws IOException {
  keySize = intKey ? BYTES : STRING_KEY_LENGTH;
  crc = new CRC32();
  final IntHashSet set = new IntHashSet(num);
  keys = new int[num];
  for (int i = 0; i < num; i++) {
    if (sequential) {
      keys[i] = i;
    } else {
      while (true) {
        int candidateKey = RND.nextInt();
        if (candidateKey < 0) {
          candidateKey *= -1;
        }
        if (!set.contains(candidateKey)) {
          set.add(candidateKey);
          keys[i] = candidateKey;
          break;
        }
      }
    }
  }

  rmdir(TMP_BENCH);
  tmp = create(b, "");
  compact = create(b, "-compacted");
}
 
Example #14
Source File: LmdbLwjgl.java    From benchmarks with Apache License 2.0 5 votes vote down vote up
public void setup(final BenchmarkParams b, final boolean sync) throws
    IOException {
  super.setup(b);

  try (MemoryStack stack = stackPush()) {
    final PointerBuffer pp = stack.mallocPointer(1);

    E(mdb_env_create(pp));
    env = pp.get(0);

    E(mdb_env_set_maxdbs(env, 1));
    E(mdb_env_set_maxreaders(env, 2));
    E(mdb_env_set_mapsize(env, mapSize(num, valSize)));

    // Open environment
    E(mdb_env_open(env, tmp.getPath(), envFlags(writeMap, sync), POSIX_MODE));

    // Open database
    E(mdb_txn_begin(env, NULL, 0, pp));
    final long txn = pp.get(0);

    final IntBuffer ip = stack.mallocInt(1);
    E(mdb_dbi_open(txn, "db", dbiFlags(intKey), ip));
    db = ip.get(0);

    mdb_txn_commit(txn);
  }
}
 
Example #15
Source File: LmdbJavaAgrona.java    From benchmarks with Apache License 2.0 5 votes vote down vote up
@Setup(Trial)
@Override
public void setup(final BenchmarkParams b) throws IOException {
  bufferProxy = PROXY_DB;
  super.setup(b, false);
  super.write();
  final int maxValSizeForCopy = 4_081; // 2nd copy requires *2 /tmp space
  if (valSize <= maxValSizeForCopy && tmp.getName().contains(".readKey-")) {
    env.copy(compact, MDB_CP_COMPACT);
    reportSpaceUsed(compact, "compacted");
  }
  txn = env.txnRead();
  c = db.openCursor(txn);
}
 
Example #16
Source File: LmdbJavaAgrona.java    From benchmarks with Apache License 2.0 5 votes vote down vote up
@Override
public void setup(final BenchmarkParams b, final boolean sync) throws
    IOException {
  super.setup(b, sync);
  keyBytes = new byte[keySize];
  valBytes = new byte[valSize];
  rwKey = new UnsafeBuffer(allocateDirect(keySize).order(LITTLE_ENDIAN));
  rwVal = new UnsafeBuffer(allocateDirect(valSize));
}
 
Example #17
Source File: CpuProfiler.java    From apm-agent-java with Apache License 2.0 5 votes vote down vote up
@Override
public Collection<? extends Result> afterIteration(BenchmarkParams benchmarkParams, IterationParams iterationParams, IterationResult result) {
    List<ScalarResult> results = new ArrayList<>();
    long allOps = result.getMetadata().getAllOps();

    long totalCpuTime = osMxBean.getProcessCpuTime() - beforeProcessCpuTime;

    results.add(new ScalarResult(Defaults.PREFIX + "cpu.time.norm",
        (allOps != 0) ? 1.0 * totalCpuTime / allOps : Double.NaN, "ns/op", AggregationPolicy.AVG));
    return results;
}
 
Example #18
Source File: GenesisMemoryProfiler.java    From hadoop-ozone with Apache License 2.0 5 votes vote down vote up
@Override
public Collection<? extends Result> afterIteration(BenchmarkParams
    benchmarkParams, IterationParams iterationParams, IterationResult
    result) {
  long totalHeap = Runtime.getRuntime().totalMemory();

  Collection<ScalarResult> samples = new ArrayList<>();
  samples.add(new ScalarResult("Max heap",
      StorageUnit.BYTES.toGBs(totalHeap), "GBs",
      AggregationPolicy.MAX));
  return samples;
}
 
Example #19
Source File: LmdbJavaByteBuffer.java    From benchmarks with Apache License 2.0 5 votes vote down vote up
@Override
public void setup(final BenchmarkParams b, final boolean sync) throws
    IOException {
  super.setup(b, sync);
  rwKey = allocateDirect(keySize).order(LITTLE_ENDIAN);
  rwVal = allocateDirect(valSize);
}
 
Example #20
Source File: LmdbJavaByteBuffer.java    From benchmarks with Apache License 2.0 5 votes vote down vote up
@Setup(Trial)
@Override
public void setup(final BenchmarkParams b) throws IOException {
  bufferProxy = forceSafe ? PROXY_SAFE : PROXY_OPTIMAL;
  super.setup(b, false);
  super.write();
  txn = env.txnRead();
  c = db.openCursor(txn);
}
 
Example #21
Source File: MapDb.java    From benchmarks with Apache License 2.0 5 votes vote down vote up
@Override
public void setup(final BenchmarkParams b) throws IOException {
  super.setup(b);
  wkb = new UnsafeBuffer(new byte[keySize]);
  wvb = new UnsafeBuffer(new byte[valSize]);
  db = fileDB(new File(tmp, "map.db"))
      .fileMmapEnable()
      .concurrencyDisable()
      .allocateStartSize(num * valSize)
      .make();
  map = db.treeMap("ba2ba")
      .keySerializer(BYTE_ARRAY)
      .valueSerializer(BYTE_ARRAY)
      .createOrOpen();
}
 
Example #22
Source File: LmdbJni.java    From benchmarks with Apache License 2.0 5 votes vote down vote up
@Setup(Trial)
@Override
public void setup(final BenchmarkParams b) throws IOException {
  super.setup(b, false);
  super.write();
  tx = env.createReadTransaction();
  c = db.bufferCursor(tx);
}
 
Example #23
Source File: SawmillBenchmark.java    From sawmill with Apache License 2.0 5 votes vote down vote up
@Setup
public void setup(BenchmarkParams params) {
    DocumentGenerator.generateDocs(docsPath, docsAmount / docsPerFile, docsPerFile, DocumentGenerator.DocType.valueOf(docType));

    setupSawmill();
    setupInput();
}
 
Example #24
Source File: JmhWaitStategyBenchmark.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * Benchmark runner
 */
public static void main(String[] args) throws RunnerException {
    List<String> policies = Arrays.asList("inc", "dec", "r25", "r50", "r75");
    int[] threads = {2, 4, 8, 16, 32};

    List<RunResult> results = new ArrayList<>();

    for (String policy : policies) {
        for (int thread : threads) {
            ChainedOptionsBuilder builder = new OptionsBuilder()
                .jvmArgs()
                .timeUnit(TimeUnit.MILLISECONDS)
                .measurementIterations(10)
                .measurementTime(TimeValue.seconds(20))
                .warmupIterations(5)
                .warmupTime(TimeValue.seconds(10))
                .jvmArgs("-Dbench.exp.policy=" + policy)
                .forks(1)
                .threads(thread)
                .mode(Mode.Throughput)
                .include(JmhWaitStategyBenchmark.class.getSimpleName());

            results.addAll(new Runner(builder.build()).run());
        }
    }

    for (RunResult result : results) {
        BenchmarkParams params = result.getParams();
        Collection<String> args1 = params.getJvmArgs();
        for (String s : args1) {
            System.out.print(s.substring(s.length() - 3, s.length()));
            System.out.print(" x ");
        }
        System.out.print(params.getThreads());
        System.out.print("\t\t");
        System.out.println(result.getPrimaryResult().toString());
    }
}
 
Example #25
Source File: StringUtilPerfTest.java    From blynk-server with GNU General Public License v3.0 5 votes vote down vote up
@Setup
public void setup(BenchmarkParams params) {
    vw_1 = "vw 1".replaceAll(" ", "\0");
    aw_1_2 = "aw 1 2".replaceAll(" ", "\0");
    vw_99_900 = "vw 99 900".replaceAll(" ", "\0");
    vw_99_22222 = "vw 99 22222.32".replaceAll(" ", "\0");
    aw_100_900 = "aw 100 200".replaceAll(" ", "\0");
    aw_10_long_text = "aw 10  dsfdsfdsfdsfdsfdsfdsfdsfd gfdsgdfg dfg dfg dfsgdf gdfs gdfsg dfsg dfsg dfs".replaceAll(" ", "\0");
}
 
Example #26
Source File: FlightRecorderProfiler.java    From cglib with Apache License 2.0 5 votes vote down vote up
@Override
public Collection<String> addJVMOptions(BenchmarkParams params) {
    StringBuilder sb = new StringBuilder();
    for (String param : params.getParamsKeys()) {
        if (sb.length() != 0) sb.append('-');
        sb.append(param).append('-').append(params.getParam(param));
    }

    long duration = getDurationSeconds(params.getWarmup()) + getDurationSeconds(params.getMeasurement());
    return Arrays.asList(
            "-XX:+UnlockCommercialFeatures", "-XX:+FlightRecorder",
            "-XX:StartFlightRecording=settings=profile,duration=" + duration + "s,filename="
                    + params.getBenchmark() + "_" + sb + ".jfr");
}
 
Example #27
Source File: PopulateParallelOnceBenchmark.java    From cache2k-benchmark with Apache License 2.0 5 votes vote down vote up
@Benchmark @BenchmarkMode(Mode.SingleShotTime)
public long populateChunkInCache(ThreadState ts, BenchmarkParams p) {
  int _chunkSize = entryCount / p.getThreads();
  int _startIndex = offset.getAndAdd(_chunkSize);
  int _endIndex = _startIndex + _chunkSize;
  for (int i = _startIndex; i < _endIndex; i++) {
    cache.put(i, (Integer) i);
  }
  ts.operations = _chunkSize;
  return _chunkSize;
}
 
Example #28
Source File: MiscResultRecorderProfiler.java    From cache2k-benchmark with Apache License 2.0 5 votes vote down vote up
@Override
public Collection<? extends Result> afterIteration(final BenchmarkParams benchmarkParams, final IterationParams iterationParams, final IterationResult result) {
  List<Result<?>> all = new ArrayList<>();
  counters.values().stream()
    .map(e ->
      new ScalarResult(SECONDARY_RESULT_PREFIX + e.key, (double) e.counter.get(), e.unit, e.aggregationPolicy))
    .sequential().forEach(e -> all.add(e));
  all.addAll(results.values());
  return all;
}
 
Example #29
Source File: ForcedGcMemoryProfiler.java    From cache2k-benchmark with Apache License 2.0 5 votes vote down vote up
@Override
public Collection<? extends Result> afterIteration(final BenchmarkParams benchmarkParams, final IterationParams iterationParams, final IterationResult result) {
  if (runOnlyAfterLastIteration) {
    if (iterationParams.getType() != IterationType.MEASUREMENT
    || iterationParams.getCount() != ++iterationNumber) {
      return Collections.emptyList();
    }
  }
  recordUsedMemory();
  List<Result> l = new ArrayList<>();
  l.addAll(Arrays.asList(
    new OptionalScalarResult("+forced-gc-mem.gcTimeMillis", (double) gcTimeMillis, "ms", AggregationPolicy.AVG),
    new OptionalScalarResult("+forced-gc-mem.usedHeap", (double) usedHeapViaHistogram, "bytes", AggregationPolicy.AVG)
  ));
  if (usageAfterIteration != null) {
  	// old metrics, t.b. removed
	l.addAll(Arrays.asList(
		new OptionalScalarResult("+forced-gc-mem.used.settled", (double) usageAfterSettled.getTotalUsed(), "bytes", AggregationPolicy.AVG),
		new OptionalScalarResult("+forced-gc-mem.used.after", (double) usageAfterIteration.getTotalUsed(), "bytes", AggregationPolicy.AVG),
		new OptionalScalarResult("+forced-gc-mem.total", (double) usageAfterSettled.getTotalCommitted(), "bytes", AggregationPolicy.AVG)
	));
	l.addAll(Arrays.asList(
		new OptionalScalarResult("+forced-gc-mem.totalUsed", (double) usageAfterSettled.getTotalUsed(), "bytes", AggregationPolicy.AVG),
		new OptionalScalarResult("+forced-gc-mem.totalUsed.after", (double) usageAfterIteration.getTotalUsed(), "bytes", AggregationPolicy.AVG),
		new OptionalScalarResult("+forced-gc-mem.totalCommitted", (double) usageAfterSettled.getTotalCommitted(), "bytes", AggregationPolicy.AVG),
		new OptionalScalarResult("+forced-gc-mem.totalCommitted.after", (double) usageAfterIteration.getTotalCommitted(), "bytes", AggregationPolicy.AVG),
		new OptionalScalarResult("+forced-gc-mem.heapUsed", (double) usageAfterSettled.heap.getUsed(), "bytes", AggregationPolicy.AVG),
		new OptionalScalarResult("+forced-gc-mem.heapUsed.after", (double) usageAfterIteration.heap.getUsed(), "bytes", AggregationPolicy.AVG)
	));
}
  LinuxVmProfiler.addLinuxVmStats("+forced-gc-mem.linuxVm", l);
  keepReference = null;
  return l;
}
 
Example #30
Source File: GcProfiler.java    From cache2k-benchmark with Apache License 2.0 5 votes vote down vote up
@Override
public void beforeIteration(BenchmarkParams benchmarkParams, IterationParams iterationParams) {
  installHooks();

  long gcTime = 0;
  long gcCount = 0;
  for (GarbageCollectorMXBean bean : ManagementFactory.getGarbageCollectorMXBeans()) {
    gcCount += bean.getCollectionCount();
    gcTime += bean.getCollectionTime();
  }
  this.beforeGCCount = gcCount;
  this.beforeGCTime = gcTime;
  this.beforeAllocated = HotspotAllocationSnapshot.create();
  this.beforeTime = System.nanoTime();
}