Skip to content

Commit

Permalink
ref: Simplifies getNodeStats.
Browse files Browse the repository at this point in the history
  • Loading branch information
bgrozev committed Mar 29, 2019
1 parent 59ea7c6 commit d588825
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/main/kotlin/org/jitsi/nlj/transform/node/Node.kt
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,12 @@ sealed class StatsKeepingNode(name: String): Node(name) {
doProcessPacket(packetInfo)
}

override fun getNodeStats(): NodeStatsBlock {
val block = NodeStatsBlock("Node $name ${hashCode()}")
stats.appendTo(block)
block.addStat(
"${stats.numInputBytes} bytes over ${Duration.ofNanos(lastPacketTime - firstPacketTime).toMillis()} ms")
block.addStat(
"throughput: ${getMbps(stats.numInputBytes, Duration.ofNanos(lastPacketTime - firstPacketTime))} mbps")

return block
override fun getNodeStats() = NodeStatsBlock("Node $name ${hashCode()}").apply {
this@StatsKeepingNode.stats.appendTo(this)
val numBytes = this@StatsKeepingNode.stats.numInputBytes
addStat("$numBytes bytes over ${Duration.ofNanos(lastPacketTime - firstPacketTime).toMillis()} ms")
addStat(
"throughput: ${getMbps(numBytes, Duration.ofNanos(lastPacketTime - firstPacketTime))} mbps")
}

private fun onEntry(packetInfo: PacketInfo) {
Expand Down

0 comments on commit d588825

Please sign in to comment.