Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions test_perf.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ fun main() {
baselineTime += measureNanoTime {
val bottomNavRoutes = BottomNavRoute.entries.map { it.route }
val showBottomBar = currentRoute in bottomNavRoutes
var count = 0
BottomNavRoute.entries.forEach { navItem ->
count++
}
val count = BottomNavRoute.entries.size

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep the benchmark's enum traversal in the timed path

When test_perf.kt is used to validate the AppNavGraph optimization, this change stops timing the second enum traversal that the app still performs while building navigation items (BottomNavRoute.entries.forEach in AppNavGraph.kt). entries.size is just a size read and does not visit each route, so the reported baseline/optimized times now omit common navigation-item iteration work and can make the refactor appear faster than the code path it is meant to model.

Useful? React with πŸ‘Β / πŸ‘Ž.

}
}

Expand All @@ -29,10 +26,7 @@ fun main() {
for(i in 1..100000) {
optimizedTime += measureNanoTime {
val showBottomBar = BottomNavRoute.entries.any { it.route == currentRoute }
var count = 0
BottomNavRoute.entries.forEach { navItem ->
count++
}
val count = BottomNavRoute.entries.size
}
}

Expand Down
Loading