Performance report is emitted only when corresponding command-line argument is provided.

This commit is contained in:
Evgeny Gerashchenko
2015-06-04 19:36:15 +03:00
parent b4190fb1fe
commit c194ced87e
3 changed files with 17 additions and 12 deletions
@@ -200,7 +200,6 @@ public class K2JVMCompiler extends CLICompiler<K2JVMCompilerArguments> {
KotlinToJVMBytecodeCompiler.compileBunchOfSources(environment, jar, outputDir, arguments.includeRuntime); KotlinToJVMBytecodeCompiler.compileBunchOfSources(environment, jar, outputDir, arguments.includeRuntime);
} }
if (arguments.reportPerf) {
PerformanceCounter.Companion.report(new Function1<String, Unit>() { PerformanceCounter.Companion.report(new Function1<String, Unit>() {
@Override @Override
public Unit invoke(String s) { public Unit invoke(String s) {
@@ -208,7 +207,6 @@ public class K2JVMCompiler extends CLICompiler<K2JVMCompilerArguments> {
return Unit.INSTANCE$; return Unit.INSTANCE$;
} }
}); });
}
return OK; return OK;
} }
catch (CompilationException e) { catch (CompilationException e) {
@@ -230,16 +228,19 @@ public class K2JVMCompiler extends CLICompiler<K2JVMCompilerArguments> {
} }
public static void reportPerf(CompilerConfiguration configuration, String message) { public static void reportPerf(CompilerConfiguration configuration, String message) {
if (configuration.get(JVMConfigurationKeys.PERFORMANCE_OUTPUT_ENABLED, false)) {
MessageCollector collector = configuration.get(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY); MessageCollector collector = configuration.get(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY);
assert collector != null; assert collector != null;
collector.report(CompilerMessageSeverity.INFO, "PERF: " + message, CompilerMessageLocation.NO_LOCATION); collector.report(CompilerMessageSeverity.INFO, "PERF: " + message, CompilerMessageLocation.NO_LOCATION);
} }
}
private static void putAdvancedOptions(@NotNull CompilerConfiguration configuration, @NotNull K2JVMCompilerArguments arguments) { private static void putAdvancedOptions(@NotNull CompilerConfiguration configuration, @NotNull K2JVMCompilerArguments arguments) {
configuration.put(JVMConfigurationKeys.DISABLE_CALL_ASSERTIONS, arguments.noCallAssertions); configuration.put(JVMConfigurationKeys.DISABLE_CALL_ASSERTIONS, arguments.noCallAssertions);
configuration.put(JVMConfigurationKeys.DISABLE_PARAM_ASSERTIONS, arguments.noParamAssertions); configuration.put(JVMConfigurationKeys.DISABLE_PARAM_ASSERTIONS, arguments.noParamAssertions);
configuration.put(JVMConfigurationKeys.DISABLE_INLINE, arguments.noInline); configuration.put(JVMConfigurationKeys.DISABLE_INLINE, arguments.noInline);
configuration.put(JVMConfigurationKeys.DISABLE_OPTIMIZATION, arguments.noOptimize); configuration.put(JVMConfigurationKeys.DISABLE_OPTIMIZATION, arguments.noOptimize);
configuration.put(JVMConfigurationKeys.PERFORMANCE_OUTPUT_ENABLED, arguments.reportPerf);
} }
/** /**
@@ -50,4 +50,7 @@ public class JVMConfigurationKeys {
public static final CompilerConfigurationKey<List<String>> MODULE_IDS = public static final CompilerConfigurationKey<List<String>> MODULE_IDS =
CompilerConfigurationKey.create("module id strings"); CompilerConfigurationKey.create("module id strings");
public static final CompilerConfigurationKey<Boolean> PERFORMANCE_OUTPUT_ENABLED =
CompilerConfigurationKey.create("performance output enabled");
} }
+1
View File
@@ -3,6 +3,7 @@ where advanced options include:
-Xno-call-assertions Don't generate not-null assertion after each invocation of method returning not-null -Xno-call-assertions Don't generate not-null assertion after each invocation of method returning not-null
-Xno-param-assertions Don't generate not-null assertions on parameters of methods accessible from Java -Xno-param-assertions Don't generate not-null assertions on parameters of methods accessible from Java
-Xno-optimize Disable optimizations -Xno-optimize Disable optimizations
-Xreport-perf Report detailed performance statistics
-Xno-inline Disable method inlining -Xno-inline Disable method inlining
-Xplugin <path> Load plugins from the given classpath -Xplugin <path> Load plugins from the given classpath