mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -07:00
Display regular logs.
This commit is contained in:
parent
c3ee130432
commit
834e48fc6d
1 changed files with 70 additions and 48 deletions
|
@ -282,60 +282,82 @@ 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()
|
||||||
|
|
||||||
// class CompressedLog(val timestamp: Long, val threadMap: HashMap<Long, String>)
|
fun displayCompressedLog(table: AsciiTable.Builder) : AsciiTable.Builder {
|
||||||
//
|
class CompressedLog(val timestamp: Long, val threadMap: HashMap<Long, String>)
|
||||||
// fun compressLog(historyLog: List<HistoryLog>): ArrayList<CompressedLog> {
|
|
||||||
// val compressed = arrayListOf<CompressedLog>()
|
|
||||||
//
|
|
||||||
// var currentLog: CompressedLog? = null
|
|
||||||
//
|
|
||||||
// historyLog.forEach { hl ->
|
|
||||||
// if (currentLog == null) {
|
|
||||||
// currentLog = CompressedLog(hl.timestamp, hashMapOf(hl.threadId to hl.name))
|
|
||||||
// } else currentLog?.let { cl ->
|
|
||||||
// if (hl.timestamp - cl.timestamp < 1000) {
|
|
||||||
// cl.threadMap[hl.threadId] = hl.name
|
|
||||||
// } else {
|
|
||||||
// compressed.add(cl)
|
|
||||||
// currentLog = null
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return compressed
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// compressLog(historyLog).forEach {
|
|
||||||
// val row = arrayListOf<String>()
|
|
||||||
// row.add(toSeconds(it.timestamp))
|
|
||||||
// it.threadMap.values.forEach {
|
|
||||||
// row.add(it)
|
|
||||||
// }
|
|
||||||
// table.addRow(row)
|
|
||||||
// }
|
|
||||||
|
|
||||||
val start = historyLog[0].timestamp
|
fun compressLog(historyLog: List<HistoryLog>): ArrayList<CompressedLog> {
|
||||||
val projectStart = ConcurrentHashMap<String, Long>()
|
val compressed = arrayListOf<CompressedLog>()
|
||||||
historyLog.forEach { line ->
|
|
||||||
val row = arrayListOf<String>()
|
var currentLog: CompressedLog? = null
|
||||||
row.add(toSeconds(line.timestamp - start))
|
|
||||||
threadIds.keys.forEach {
|
val projectStart = hashMapOf<String, Long>()
|
||||||
if (line.threadId == it) {
|
historyLog.forEach { hl ->
|
||||||
var duration = ""
|
if (hl.start) {
|
||||||
if (line.start) {
|
projectStart[hl.name] = hl.timestamp
|
||||||
projectStart[line.name] = line.timestamp
|
}
|
||||||
} else {
|
if (currentLog == null) {
|
||||||
duration = " (" + ((line.timestamp - projectStart[line.name]!!) / 1000)
|
currentLog = CompressedLog(hl.timestamp, hashMapOf(hl.threadId to hl.name))
|
||||||
.toInt().toString() + ")"
|
} else currentLog?.let { cl ->
|
||||||
|
if (hl.timestamp - cl.timestamp < 1000) {
|
||||||
|
var duration = ""
|
||||||
|
if (! hl.start) {
|
||||||
|
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 {
|
||||||
|
compressed.add(cl)
|
||||||
|
currentLog = null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
row.add((line.name + duration))
|
|
||||||
} else {
|
|
||||||
row.add("")
|
|
||||||
}
|
}
|
||||||
|
return compressed
|
||||||
}
|
}
|
||||||
table.addRow(row)
|
|
||||||
|
compressLog(historyLog).forEach {
|
||||||
|
val row = arrayListOf<String>()
|
||||||
|
row.add(toSeconds(it.timestamp))
|
||||||
|
it.threadMap.values.forEach {
|
||||||
|
row.add(it)
|
||||||
|
}
|
||||||
|
table.addRow(row)
|
||||||
|
}
|
||||||
|
|
||||||
|
return table
|
||||||
}
|
}
|
||||||
|
|
||||||
println(table.build())
|
fun displayRegularLog(table: AsciiTable.Builder) : AsciiTable.Builder {
|
||||||
|
val start = historyLog[0].timestamp
|
||||||
|
val projectStart = ConcurrentHashMap<String, Long>()
|
||||||
|
historyLog.forEach { line ->
|
||||||
|
val row = arrayListOf<String>()
|
||||||
|
row.add(toSeconds(line.timestamp - start))
|
||||||
|
threadIds.keys.forEach {
|
||||||
|
if (line.threadId == it) {
|
||||||
|
var duration = ""
|
||||||
|
if (line.start) {
|
||||||
|
projectStart[line.name] = line.timestamp
|
||||||
|
} else {
|
||||||
|
duration = " (" + ((line.timestamp - projectStart[line.name]!!) / 1000)
|
||||||
|
.toInt().toString() + ")"
|
||||||
|
}
|
||||||
|
row.add((line.name + duration))
|
||||||
|
} else {
|
||||||
|
row.add("")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
table.addRow(row)
|
||||||
|
}
|
||||||
|
return table
|
||||||
|
}
|
||||||
|
|
||||||
|
println(displayRegularLog(table).build())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue