restore perf output in command line; always remove it from output in tests
This commit is contained in:
@@ -214,13 +214,15 @@ public class K2JVMCompiler extends CLICompiler<K2JVMCompilerArguments> {
|
||||
KotlinToJVMBytecodeCompiler.compileBunchOfSources(environment, jar, outputDir, arguments.includeRuntime);
|
||||
}
|
||||
|
||||
PerformanceCounter.Companion.report(new Function1<String, Unit>() {
|
||||
@Override
|
||||
public Unit invoke(String s) {
|
||||
reportPerf(environment.getConfiguration(), s);
|
||||
return Unit.INSTANCE$;
|
||||
}
|
||||
});
|
||||
if (arguments.reportPerf) {
|
||||
PerformanceCounter.Companion.report(new Function1<String, Unit>() {
|
||||
@Override
|
||||
public Unit invoke(String s) {
|
||||
reportPerf(environment.getConfiguration(), s);
|
||||
return Unit.INSTANCE$;
|
||||
}
|
||||
});
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
catch (CompilationException e) {
|
||||
@@ -237,16 +239,14 @@ public class K2JVMCompiler extends CLICompiler<K2JVMCompilerArguments> {
|
||||
rootDisposable, configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public static void reportPerf(CompilerConfiguration configuration, String message) {
|
||||
if (configuration.get(JVMConfigurationKeys.PERFORMANCE_OUTPUT_ENABLED, false)) {
|
||||
MessageCollector collector = configuration.get(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY);
|
||||
assert collector != null;
|
||||
collector.report(CompilerMessageSeverity.INFO, "PERF: " + message, CompilerMessageLocation.NO_LOCATION);
|
||||
}
|
||||
MessageCollector collector = configuration.get(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY);
|
||||
assert collector != null;
|
||||
collector.report(CompilerMessageSeverity.INFO, "PERF: " + message, CompilerMessageLocation.NO_LOCATION);
|
||||
}
|
||||
|
||||
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_INLINE, arguments.noInline);
|
||||
configuration.put(JVMConfigurationKeys.DISABLE_OPTIMIZATION, arguments.noOptimize);
|
||||
configuration.put(JVMConfigurationKeys.PERFORMANCE_OUTPUT_ENABLED, arguments.reportPerf);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+2
-2
@@ -320,7 +320,7 @@ public class KotlinToJVMBytecodeCompiler {
|
||||
}
|
||||
);
|
||||
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";
|
||||
K2JVMCompiler.reportPerf(environment.getConfiguration(), message);
|
||||
|
||||
@@ -381,7 +381,7 @@ public class KotlinToJVMBytecodeCompiler {
|
||||
KotlinCodegenFacade.compileCorrectFiles(generationState, CompilationErrorHandler.THROW_EXCEPTION);
|
||||
|
||||
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";
|
||||
K2JVMCompiler.reportPerf(environment.getConfiguration(), message);
|
||||
|
||||
|
||||
@@ -50,7 +50,4 @@ public class JVMConfigurationKeys {
|
||||
|
||||
public static final CompilerConfigurationKey<List<String>> MODULE_IDS =
|
||||
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);
|
||||
StringBuilder result = new StringBuilder();
|
||||
for (String line : lines) {
|
||||
if (!line.contains("INFO: PERF:")) {
|
||||
if (!line.contains("PERF:")) {
|
||||
result.append(line);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package org.jetbrains.kotlin.integration;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.cli.CliBaseTest;
|
||||
import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime;
|
||||
|
||||
import java.io.File;
|
||||
@@ -42,7 +41,7 @@ public abstract class AbstractAntTaskTest extends KotlinIntegrationTestBase {
|
||||
@Override
|
||||
@NotNull
|
||||
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");
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ import kotlin.text.Regex;
|
||||
import org.intellij.lang.annotations.Language;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.cli.CliBaseTest;
|
||||
import org.jetbrains.kotlin.cli.common.KotlinVersion;
|
||||
import org.jetbrains.kotlin.test.JetTestUtils;
|
||||
import org.jetbrains.kotlin.test.TestCaseWithTmpdir;
|
||||
@@ -83,6 +84,7 @@ public abstract class KotlinIntegrationTestBase extends TestCaseWithTmpdir {
|
||||
content = normalizePath(content, getKotlinProjectHome(), "[KotlinProjectHome]");
|
||||
content = content.replaceAll(KotlinVersion.VERSION, "[KotlinVersion]");
|
||||
content = StringUtil.convertLineSeparators(content);
|
||||
content = CliBaseTest.removePerfOutput(content);
|
||||
return content;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user