in src/org/pushingpixels/lightbeam/DynamicPerformanceSuite.java [439:531]
public static void main(final String[] args) {
try {
setLookAndFeel();
} catch (UnsupportedLookAndFeelException | IllegalAccessException | InstantiationException
| ClassNotFoundException e) {
e.printStackTrace();
System.exit(1);
}
initControlsFactory();
boolean prepareTCChart = System.getProperty("tcchart.enable", "").toLowerCase().contains("true");
SwingUtilities.invokeLater(() -> {
JFrame.setDefaultLookAndFeelDecorated(true);
final DynamicPerformanceSuite suite = new DynamicPerformanceSuite();
suite.initialize();
if (args.length > 0) {
Runnable auto = new Runnable() {
@Override
public void run() {
int loopCount = Integer.parseInt(args[0]);
String specificScenarioId = null;
if (args.length == 2) {
specificScenarioId = args[1];
}
int warmups = 5;
System.out.println("Look-and-Feel: " + lafClass);
System.out.println("Controls: " + factory.getType());
for (int i = 0; i < loopCount + warmups; i++) {
suite.runSingleRound(i >= warmups, specificScenarioId);
}
long totalMin = 0;
StringBuilder tcReport = new StringBuilder();
for (ScenarioTimesInfo timesInfo : suite.scenarioTimes) {
List<Long> times = timesInfo.times;
long avg = 0;
for (long time : times) {
avg += time;
}
avg /= times.size();
long min = times.get(0);
for (long time : times) {
min = Math.min(min, time);
}
long max = times.get(0);
for (long time : times) {
max = Math.max(max, time);
}
double deviance = 0;
for (long time : times) {
deviance += (time - avg) * (time - avg);
}
deviance = Math.sqrt(deviance / times.size()) / avg;
StringBuilder sb = new StringBuilder();
Formatter formatter = new Formatter(sb, Locale.US);
formatter.format(
"avg %1$5d, min %2$5d, max %3$5d, dev %4$4.2f %5$15s : %6$s",
avg, min, max, deviance, timesInfo.tabTitle,
timesInfo.scenarioName);
if (prepareTCChart) {
StringBuilder tcSb = new StringBuilder();
Formatter tcFormatter = new Formatter(tcSb, Locale.US);
tcFormatter.format(
"##teamcity[buildStatisticValue key='%7$s:%5$s:%6$s' value='%1$d']",
//"avg %1$4d, min %2$4d, max %3$4d, dev %4$4.2f %5$15s : %6$s",
avg, min, max, deviance,
("JDK".equals(factory.getType()) ? "": "JB_") +
timesInfo.tabTitle.replace(' ', '_'),
timesInfo.scenarioName.replace(' ', '_'),
lafClass.substring(lafClass.lastIndexOf(".") + 1).trim());
tcFormatter.close();
tcReport.append(tcSb.toString() + "\n");
}
formatter.close();
System.out.println(sb.toString());
totalMin += min;
}
System.out.println("\n" + totalMin + " totalMin");
if (prepareTCChart) {
System.out.println("\n\n" + tcReport);
}
System.exit(0);
}
};
Executors.newCachedThreadPool().execute(auto);
}
});
}