Skip to content

Commit

Permalink
Merge pull request #31 from lenguyenthanh/lilaism
Browse files Browse the repository at this point in the history
Optimize with groupMapReduce
  • Loading branch information
ornicar authored Apr 28, 2024
2 parents 4e99d87 + 5567b53 commit 7dd761d
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions lila/src/main/scala/jvm.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@ object Jvm:
override def toString = s"$name total: $total runnable: $running"

def threadGroups(): List[ThreadGroup] = threadList()
.map { thread => """-\d+$""".r.replaceAllIn(thread.getName, "") -> thread.getState }
.map(thread => """-\d+$""".r.replaceAllIn(thread.getName, "") -> thread.getState)
.groupBy(_._1)
.view
.map { (name, states) =>
ThreadGroup(name, states.groupBy(_._2).view.mapValues(_.size).toMap)
}
.map((name, states) => ThreadGroup(name, states.groupMapReduce(_._2)(_ => 1)(_ + _)))
.toList
.sortBy(-_.total)

Expand Down

0 comments on commit 7dd761d

Please sign in to comment.