1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt.git synced 2025-04-26 08:27:12 -07:00

Added --profiling.

This commit is contained in:
Cedric Beust 2016-07-24 22:39:43 -08:00
parent f8d2d0ed23
commit 888e5cde73
3 changed files with 17 additions and 5 deletions

View file

@ -65,6 +65,9 @@ class Args {
@Parameter(names = arrayOf("--profiles"), description = "Comma-separated list of profiles to run")
var profiles: String? = null
@Parameter(names = arrayOf("--profiling"), description = "Display task timings at the end of the build")
var profiling: Boolean = false
@Parameter(names = arrayOf("--resolve"),
description = "Resolve the given comma-separated dependencies and display their dependency tree")
var dependencies: String? = null

View file

@ -62,7 +62,7 @@ class TaskManager @Inject constructor(val args: Args,
override fun toString() = id
}
class RunTargetResult(val taskResult: TaskResult, val messages: List<String>)
class RunTargetResult(val taskResult: TaskResult, val timings: List<ProfilerInfo>)
/**
* @return the list of tasks available for the given project.
@ -124,10 +124,12 @@ class TaskManager @Inject constructor(val args: Args,
return if (result.any()) result.toList() else projects
}
class ProfilerInfo(val taskName: String, val durationMillis: Long)
private fun runProjects(taskInfos: List<TaskInfo>, projects: List<Project>) : RunTargetResult {
var result = TaskResult()
val failedProjects = hashSetOf<String>()
val messages = Collections.synchronizedList(arrayListOf<String>())
val messages = Collections.synchronizedList(arrayListOf<ProfilerInfo>())
projects.forEach { project ->
AsciiArt.logBox("Building ${project.name}")
@ -532,7 +534,7 @@ class TaskManager @Inject constructor(val args: Args,
/////
}
class TaskWorker(val tasks: List<ITask>, val dryRun: Boolean, val messages: MutableList<String>)
class TaskWorker(val tasks: List<ITask>, val dryRun: Boolean, val timings: MutableList<TaskManager.ProfilerInfo>)
: IWorker<ITask> {
override fun call() : TaskResult2<ITask> {
@ -550,7 +552,7 @@ class TaskWorker(val tasks: List<ITask>, val dryRun: Boolean, val messages: Muta
success = success and tr.success
if (tr.errorMessage != null) errorMessages.add(tr.errorMessage)
}
messages.add("$name: $time ms")
timings.add(TaskManager.ProfilerInfo(name, time.first))
}
return TaskResult2(success, errorMessages.joinToString("\n"), tasks[0])
}