restore perf output in command line; always remove it from output in tests

This commit is contained in:
Dmitry Jemerov
2015-06-08 18:04:42 +02:00
parent 342f35fb65
commit ab33e4935e
6 changed files with 19 additions and 22 deletions
@@ -214,13 +214,15 @@ public class K2JVMCompiler extends CLICompiler<K2JVMCompilerArguments> {
KotlinToJVMBytecodeCompiler.compileBunchOfSources(environment, jar, outputDir, arguments.includeRuntime); KotlinToJVMBytecodeCompiler.compileBunchOfSources(environment, jar, outputDir, arguments.includeRuntime);
} }
PerformanceCounter.Companion.report(new Function1<String, Unit>() { if (arguments.reportPerf) {
@Override PerformanceCounter.Companion.report(new Function1<String, Unit>() {
public Unit invoke(String s) { @Override
reportPerf(environment.getConfiguration(), s); public Unit invoke(String s) {
return Unit.INSTANCE$; reportPerf(environment.getConfiguration(), s);
} return Unit.INSTANCE$;
}); }
});
}
return OK; return OK;
} }
catch (CompilationException e) { catch (CompilationException e) {
@@ -237,16 +239,14 @@ public class K2JVMCompiler extends CLICompiler<K2JVMCompilerArguments> {
rootDisposable, configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES); rootDisposable, configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES);
long initNanos = System.nanoTime() - initStartNanos; long initNanos = System.nanoTime() - initStartNanos;
reportPerf(configuration, "Compiler initialized in " + TimeUnit.NANOSECONDS.toMillis(initNanos) + " ms"); reportPerf(configuration, "INIT: Compiler initialized in " + TimeUnit.NANOSECONDS.toMillis(initNanos) + " ms");
return result; return result;
} }
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) {
@@ -254,7 +254,6 @@ public class K2JVMCompiler extends CLICompiler<K2JVMCompilerArguments> {
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);
} }
/** /**
@@ -320,7 +320,7 @@ public class KotlinToJVMBytecodeCompiler {
} }
); );
long analysisNanos = PerformanceCounter.Companion.currentThreadCpuTime() - analysisStart; long analysisNanos = PerformanceCounter.Companion.currentThreadCpuTime() - analysisStart;
String message = "Analyzed " + environment.getSourceFiles().size() + " files (" + String message = "ANALYZE: " + environment.getSourceFiles().size() + " files (" +
environment.getSourceLinesOfCode() + " lines) in " + TimeUnit.NANOSECONDS.toMillis(analysisNanos) + " ms"; environment.getSourceLinesOfCode() + " lines) in " + TimeUnit.NANOSECONDS.toMillis(analysisNanos) + " ms";
K2JVMCompiler.reportPerf(environment.getConfiguration(), message); K2JVMCompiler.reportPerf(environment.getConfiguration(), message);
@@ -381,7 +381,7 @@ public class KotlinToJVMBytecodeCompiler {
KotlinCodegenFacade.compileCorrectFiles(generationState, CompilationErrorHandler.THROW_EXCEPTION); KotlinCodegenFacade.compileCorrectFiles(generationState, CompilationErrorHandler.THROW_EXCEPTION);
long generationNanos = PerformanceCounter.Companion.currentThreadCpuTime() - generationStart; long generationNanos = PerformanceCounter.Companion.currentThreadCpuTime() - generationStart;
String message = "Generated " + sourceFiles.size() + " files (" + String message = "GENERATE: " + sourceFiles.size() + " files (" +
environment.countLinesOfCode(sourceFiles) + " lines) in " + TimeUnit.NANOSECONDS.toMillis(generationNanos) + " ms"; environment.countLinesOfCode(sourceFiles) + " lines) in " + TimeUnit.NANOSECONDS.toMillis(generationNanos) + " ms";
K2JVMCompiler.reportPerf(environment.getConfiguration(), message); K2JVMCompiler.reportPerf(environment.getConfiguration(), message);
@@ -50,7 +50,4 @@ 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");
} }
@@ -81,7 +81,7 @@ public class CliBaseTest {
String[] lines = StringUtil.splitByLinesKeepSeparators(output); String[] lines = StringUtil.splitByLinesKeepSeparators(output);
StringBuilder result = new StringBuilder(); StringBuilder result = new StringBuilder();
for (String line : lines) { for (String line : lines) {
if (!line.contains("INFO: PERF:")) { if (!line.contains("PERF:")) {
result.append(line); result.append(line);
} }
} }
@@ -17,7 +17,6 @@
package org.jetbrains.kotlin.integration; package org.jetbrains.kotlin.integration;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.cli.CliBaseTest;
import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime; import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime;
import java.io.File; import java.io.File;
@@ -42,7 +41,7 @@ public abstract class AbstractAntTaskTest extends KotlinIntegrationTestBase {
@Override @Override
@NotNull @NotNull
protected String normalizeOutput(@NotNull File testDataDir, @NotNull String content) { protected String normalizeOutput(@NotNull File testDataDir, @NotNull String content) {
return CliBaseTest.removePerfOutput(super.normalizeOutput(testDataDir, content)) return super.normalizeOutput(testDataDir, content)
.replaceAll("Total time: .+\n", "Total time: [time]\n"); .replaceAll("Total time: .+\n", "Total time: [time]\n");
} }
@@ -30,6 +30,7 @@ import kotlin.text.Regex;
import org.intellij.lang.annotations.Language; import org.intellij.lang.annotations.Language;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.cli.CliBaseTest;
import org.jetbrains.kotlin.cli.common.KotlinVersion; import org.jetbrains.kotlin.cli.common.KotlinVersion;
import org.jetbrains.kotlin.test.JetTestUtils; import org.jetbrains.kotlin.test.JetTestUtils;
import org.jetbrains.kotlin.test.TestCaseWithTmpdir; import org.jetbrains.kotlin.test.TestCaseWithTmpdir;
@@ -83,6 +84,7 @@ public abstract class KotlinIntegrationTestBase extends TestCaseWithTmpdir {
content = normalizePath(content, getKotlinProjectHome(), "[KotlinProjectHome]"); content = normalizePath(content, getKotlinProjectHome(), "[KotlinProjectHome]");
content = content.replaceAll(KotlinVersion.VERSION, "[KotlinVersion]"); content = content.replaceAll(KotlinVersion.VERSION, "[KotlinVersion]");
content = StringUtil.convertLineSeparators(content); content = StringUtil.convertLineSeparators(content);
content = CliBaseTest.removePerfOutput(content);
return content; return content;
} }