mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -07:00
Playing with thread log display.
This commit is contained in:
parent
cad5984dae
commit
39c1b6f8d3
1 changed files with 22 additions and 16 deletions
|
@ -189,7 +189,7 @@ class DynamicGraphExecutor<T>(val graph : DynamicGraph<T>, val factory: IThreadW
|
||||||
= Executors.newFixedThreadPool(threadCount, NamedThreadFactory("DynamicGraphExecutor"))
|
= Executors.newFixedThreadPool(threadCount, NamedThreadFactory("DynamicGraphExecutor"))
|
||||||
val completion = ExecutorCompletionService<TaskResult2<T>>(executor)
|
val completion = ExecutorCompletionService<TaskResult2<T>>(executor)
|
||||||
|
|
||||||
class HistoryLog(val name: String, val timestamp: Long, val threadId: Long, val start: Boolean)
|
data class HistoryLog(val name: String, val timestamp: Long, val threadId: Long, val start: Boolean)
|
||||||
|
|
||||||
val historyLog = arrayListOf<HistoryLog>()
|
val historyLog = arrayListOf<HistoryLog>()
|
||||||
val threadIds = ConcurrentHashMap<Long, Long>()
|
val threadIds = ConcurrentHashMap<Long, Long>()
|
||||||
|
@ -283,7 +283,7 @@ class DynamicGraphExecutor<T>(val graph : DynamicGraph<T>, val factory: IThreadW
|
||||||
fun toSeconds(millis: Long) = (millis / 1000).toInt().toString()
|
fun toSeconds(millis: Long) = (millis / 1000).toInt().toString()
|
||||||
|
|
||||||
fun displayCompressedLog(table: AsciiTable.Builder) : AsciiTable.Builder {
|
fun displayCompressedLog(table: AsciiTable.Builder) : AsciiTable.Builder {
|
||||||
class CompressedLog(val timestamp: Long, val threadMap: HashMap<Long, String>)
|
data class CompressedLog(val timestamp: Long, val threadMap: HashMap<Long, String>)
|
||||||
|
|
||||||
fun compressLog(historyLog: List<HistoryLog>): ArrayList<CompressedLog> {
|
fun compressLog(historyLog: List<HistoryLog>): ArrayList<CompressedLog> {
|
||||||
val compressed = arrayListOf<CompressedLog>()
|
val compressed = arrayListOf<CompressedLog>()
|
||||||
|
@ -291,29 +291,35 @@ class DynamicGraphExecutor<T>(val graph : DynamicGraph<T>, val factory: IThreadW
|
||||||
var currentLog: CompressedLog? = null
|
var currentLog: CompressedLog? = null
|
||||||
|
|
||||||
val projectStart = hashMapOf<String, Long>()
|
val projectStart = hashMapOf<String, Long>()
|
||||||
|
fun toName(hl: HistoryLog) : String {
|
||||||
|
var duration = ""
|
||||||
|
if (! hl.start) {
|
||||||
|
val start = projectStart[hl.name]
|
||||||
|
if (start != null) {
|
||||||
|
duration = " (" + ((hl.timestamp - start) / 1000)
|
||||||
|
.toInt().toString() + ")"
|
||||||
|
} else {
|
||||||
|
println("DONOTCOMMIT")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return hl.name + duration
|
||||||
|
}
|
||||||
|
|
||||||
historyLog.forEach { hl ->
|
historyLog.forEach { hl ->
|
||||||
|
println("CURRENT LOG: " + currentLog + " HISTORY LINE: " + hl)
|
||||||
if (hl.start) {
|
if (hl.start) {
|
||||||
projectStart[hl.name] = hl.timestamp
|
projectStart[hl.name] = hl.timestamp
|
||||||
}
|
}
|
||||||
if (currentLog == null) {
|
if (currentLog == null) {
|
||||||
currentLog = CompressedLog(hl.timestamp, hashMapOf(hl.threadId to hl.name))
|
currentLog = CompressedLog(hl.timestamp, hashMapOf(hl.threadId to hl.name))
|
||||||
} else currentLog?.let { cl ->
|
} else currentLog?.let { cl ->
|
||||||
if (hl.timestamp - cl.timestamp < 1000) {
|
if (! hl.start || hl.timestamp - cl.timestamp < 1000) {
|
||||||
var duration = ""
|
println(" CURRENT LOG IS WITHING ONE SECOND: $hl")
|
||||||
if (! hl.start) {
|
cl.threadMap[hl.threadId] = toName(hl)
|
||||||
val start = projectStart[hl.name]
|
|
||||||
if (start != null) {
|
|
||||||
duration = " (" + ((hl.timestamp - start) / 1000)
|
|
||||||
.toInt().toString() + ")"
|
|
||||||
} else {
|
|
||||||
println("DONOTCOMMIT")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cl.threadMap[hl.threadId] = hl.name + duration
|
|
||||||
} else {
|
} else {
|
||||||
|
println(" ADDING COMPRESSED LINE $cl")
|
||||||
compressed.add(cl)
|
compressed.add(cl)
|
||||||
currentLog = null
|
currentLog = CompressedLog(hl.timestamp, hashMapOf(hl.threadId to toName(hl)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue