Search in sources :

Example 11 with Timer

use of org.gradle.internal.time.Timer in project gradle by gradle.

the class ClassSetAnalysisUpdater method updateAnalysis.

public void updateAnalysis(JavaCompileSpec spec) {
    Timer clock = Timers.startTimer();
    Set<File> baseDirs = Sets.newLinkedHashSet();
    baseDirs.add(spec.getDestinationDir());
    Iterables.addAll(baseDirs, Iterables.filter(spec.getCompileClasspath(), IS_CLASS_DIRECTORY));
    ClassFilesAnalyzer analyzer = new ClassFilesAnalyzer(this.analyzer, fileHasher);
    for (File baseDir : baseDirs) {
        fileOperations.fileTree(baseDir).visit(analyzer);
    }
    ClassSetAnalysisData data = analyzer.getAnalysis();
    stash.put(data);
    LOG.info("Class dependency analysis for incremental compilation took {}.", clock.getElapsed());
}
Also used : Timer(org.gradle.internal.time.Timer) ClassFilesAnalyzer(org.gradle.api.internal.tasks.compile.incremental.analyzer.ClassFilesAnalyzer) ClassSetAnalysisData(org.gradle.api.internal.tasks.compile.incremental.deps.ClassSetAnalysisData) File(java.io.File)

Example 12 with Timer

use of org.gradle.internal.time.Timer in project gradle by gradle.

the class TransientConfigurationResultsBuilder method deserialize.

private TransientConfigurationResults deserialize(Decoder decoder, ResolvedGraphResults graphResults, SelectedArtifactResults artifactResults, BuildOperationExecutor buildOperationProcessor) {
    Timer clock = Time.startTimer();
    Map<Long, DefaultResolvedDependency> allDependencies = new HashMap<Long, DefaultResolvedDependency>();
    Map<Dependency, DependencyGraphNodeResult> firstLevelDependencies = new LinkedHashMap<Dependency, DependencyGraphNodeResult>();
    DependencyGraphNodeResult root;
    int valuesRead = 0;
    byte type = -1;
    long id;
    ResolvedArtifactSet artifacts;
    try {
        while (true) {
            type = decoder.readByte();
            valuesRead++;
            switch(type) {
                case NODE:
                    id = decoder.readSmallLong();
                    ResolvedConfigurationIdentifier details = resolvedConfigurationIdentifierSerializer.read(decoder);
                    allDependencies.put(id, new DefaultResolvedDependency(id, details, buildOperationProcessor));
                    break;
                case ROOT:
                    id = decoder.readSmallLong();
                    root = allDependencies.get(id);
                    if (root == null) {
                        throw new IllegalStateException(String.format("Unexpected root id %s. Seen ids: %s", id, allDependencies.keySet()));
                    }
                    // root should be the last entry
                    LOG.debug("Loaded resolved configuration results ({}) from {}", clock.getElapsed(), binaryStore);
                    return new DefaultTransientConfigurationResults(root, firstLevelDependencies);
                case FIRST_LEVEL:
                    id = decoder.readSmallLong();
                    DefaultResolvedDependency dependency = allDependencies.get(id);
                    if (dependency == null) {
                        throw new IllegalStateException(String.format("Unexpected first level id %s. Seen ids: %s", id, allDependencies.keySet()));
                    }
                    firstLevelDependencies.put(graphResults.getModuleDependency(id), dependency);
                    break;
                case EDGE:
                    long parentId = decoder.readSmallLong();
                    long childId = decoder.readSmallLong();
                    DefaultResolvedDependency parent = allDependencies.get(parentId);
                    DefaultResolvedDependency child = allDependencies.get(childId);
                    if (parent == null) {
                        throw new IllegalStateException(String.format("Unexpected parent dependency id %s. Seen ids: %s", parentId, allDependencies.keySet()));
                    }
                    if (child == null) {
                        throw new IllegalStateException(String.format("Unexpected child dependency id %s. Seen ids: %s", childId, allDependencies.keySet()));
                    }
                    parent.addChild(child);
                    artifacts = artifactResults.getArtifactsWithId(decoder.readSmallInt());
                    child.addParentSpecificArtifacts(parent, artifacts);
                    break;
                case NODE_ARTIFACTS:
                    id = decoder.readSmallLong();
                    DefaultResolvedDependency node = allDependencies.get(id);
                    if (node == null) {
                        throw new IllegalStateException(String.format("Unexpected node id %s. Seen ids: %s", node, allDependencies.keySet()));
                    }
                    artifacts = artifactResults.getArtifactsWithId(decoder.readSmallInt());
                    node.addModuleArtifacts(artifacts);
                    break;
                default:
                    throw new IOException("Unknown value type read from stream: " + type);
            }
        }
    } catch (IOException e) {
        throw new RuntimeException("Problems loading the resolved configuration. Read " + valuesRead + " values, last was: " + type, e);
    }
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ResolvedArtifactSet(org.gradle.api.internal.artifacts.ivyservice.resolveengine.artifact.ResolvedArtifactSet) DefaultResolvedDependency(org.gradle.api.internal.artifacts.DefaultResolvedDependency) DefaultResolvedDependency(org.gradle.api.internal.artifacts.DefaultResolvedDependency) Dependency(org.gradle.api.artifacts.Dependency) IOException(java.io.IOException) LinkedHashMap(java.util.LinkedHashMap) DependencyGraphNodeResult(org.gradle.api.internal.artifacts.DependencyGraphNodeResult) Timer(org.gradle.internal.time.Timer) ResolvedConfigurationIdentifier(org.gradle.api.internal.artifacts.ResolvedConfigurationIdentifier)

Example 13 with Timer

use of org.gradle.internal.time.Timer in project gradle by gradle.

the class ResolutionResultsStoreFactory method close.

public void close() {
    try {
        Timer clock = Time.startTimer();
        cleanUpLater.stop();
        LOG.debug("Deleted {} resolution results binary files in {}", stores.size(), clock.getElapsed());
    } finally {
        oldModelCache = null;
        newModelCache = null;
        stores.clear();
    }
}
Also used : Timer(org.gradle.internal.time.Timer)

Example 14 with Timer

use of org.gradle.internal.time.Timer in project gradle by gradle.

the class DefaultTaskGraphExecuter method addTasks.

public void addTasks(Iterable<? extends Task> tasks) {
    assert tasks != null;
    final Timer clock = Time.startTimer();
    Set<Task> taskSet = new LinkedHashSet<Task>();
    for (Task task : tasks) {
        taskSet.add(task);
        requestedTasks.add(task);
    }
    taskExecutionPlan.addToTaskGraph(taskSet);
    taskGraphState = TaskGraphState.DIRTY;
    LOGGER.debug("Timing: Creating the DAG took " + clock.getElapsed());
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Task(org.gradle.api.Task) Timer(org.gradle.internal.time.Timer)

Example 15 with Timer

use of org.gradle.internal.time.Timer in project gradle by gradle.

the class ClassSetAnalysisUpdater method updateAnalysis.

public void updateAnalysis(JavaCompileSpec spec, WorkResult result) {
    if (result instanceof RecompilationNotNecessary) {
        return;
    }
    Timer clock = Time.startTimer();
    CompilationResultAnalyzer analyzer = new CompilationResultAnalyzer(this.analyzer, fileHasher);
    visitAnnotationProcessingResult(spec, result, analyzer);
    visitClassFiles(spec, analyzer);
    ClassSetAnalysisData data = analyzer.getAnalysis();
    stash.put(data);
    LOG.info("Class dependency analysis for incremental compilation took {}.", clock.getElapsed());
}
Also used : Timer(org.gradle.internal.time.Timer) ClassSetAnalysisData(org.gradle.api.internal.tasks.compile.incremental.deps.ClassSetAnalysisData) CompilationResultAnalyzer(org.gradle.api.internal.tasks.compile.incremental.analyzer.CompilationResultAnalyzer)

Aggregations

Timer (org.gradle.internal.time.Timer)21 IOException (java.io.IOException)4 File (java.io.File)3 HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 GradleException (org.gradle.api.GradleException)2 DefaultResolvedDependency (org.gradle.api.internal.artifacts.DefaultResolvedDependency)2 DependencyGraphNodeResult (org.gradle.api.internal.artifacts.DependencyGraphNodeResult)2 ResolvedConfigurationIdentifier (org.gradle.api.internal.artifacts.ResolvedConfigurationIdentifier)2 ClassSetAnalysisData (org.gradle.api.internal.tasks.compile.incremental.deps.ClassSetAnalysisData)2 JavaExecHandleBuilder (org.gradle.process.internal.JavaExecHandleBuilder)2 WorkerProcess (org.gradle.process.internal.worker.WorkerProcess)2 FilenameFilter (java.io.FilenameFilter)1 LinkedHashSet (java.util.LinkedHashSet)1 CompilerConfiguration (org.codehaus.groovy.control.CompilerConfiguration)1 Action (org.gradle.api.Action)1 Task (org.gradle.api.Task)1 UncheckedIOException (org.gradle.api.UncheckedIOException)1 Dependency (org.gradle.api.artifacts.Dependency)1 ModuleDependency (org.gradle.api.artifacts.ModuleDependency)1