Skip to content

Instantly share code, notes, and snippets.

@oowekyala
Created November 7, 2025 16:31
Show Gist options
  • Select an option

  • Save oowekyala/2be2e438c060cffde86dac8b3fd09ceb to your computer and use it in GitHub Desktop.

Select an option

Save oowekyala/2be2e438c060cffde86dac8b3fd09ceb to your computer and use it in GitHub Desktop.
Wrapper for PMD to run some warmup iterations and dump timing numbers to stdout. Drop this in the pmd-cli module.
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.cli;
import org.apache.commons.lang3.ArrayUtils;
public class BenchmarkPmd {
public static void main(String[] args) {
int runs = Integer.parseInt(args[0]);
int warmup = Integer.parseInt(args[1]);
String[] pmdArgs = ArrayUtils.subarray(args, 2, args.length);
// warmup iterations are discarded
for (int i = 0; i < warmup; i++) {
PmdCli.mainWithoutExit(pmdArgs);
}
System.out.println("time_sec"); // one line as CSV header
for (int i = 0; i < runs; i++) {
long t0 = System.nanoTime();
// Note that this relies on PMD not printing anything to stdout.
// Use renderer empty (or dump report to a file) and no progress bar.
PmdCli.mainWithoutExit(pmdArgs);
long time = System.nanoTime() - t0;
System.out.println(time / 1e9);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment