What is more performant: 1. ```days.groupBy { it....
# announcements
j
What is more performant: 1.
Copy code
days.groupBy { it.date.year }.forEach { (year, daysOfYear) ->
    daysOfYear.groupBy { it.date.month }.forEach { (month, daysOfMonth) ->
      aysOfMonth.groupBy { it.date.weekNumber() }.forEach { (week, daysOfWeek) ->
}}}
2.
Copy code
days.groupBy { Triple(it.date.year, it.date.month, it.date.weekNumber()) }.forEach { (triple, days) ->
}
f
Benchmark it, but I would say 2.
j
the overheads for stdlib tuple/dataclass creation should be considered as potentially larger functions than discrete assignments. larger functions influence the inline decisions. escape analysis follows inlining. kotlin's tuples went with serializable final classes and not with interfaces. a good benchmark would test all three. this seems like an interesting benchmark to write. you can use the jvm escape analysis and inlining switches to eyeball it for your own code and see what compilation decisions are made from a given unit test.
-XX:MaxInlineSize is your friend. sort of.
image.png