jhawthorn / vernier

📏 next generation CRuby profiler
https://vernier.prof/
MIT License
718 stars 15 forks source link

Show all threads and pre-select profile start thread by default #78

Closed joshuay03 closed 1 week ago

joshuay03 commented 1 week ago

Closes https://github.com/jhawthorn/vernier/issues/56 Related to https://github.com/jhawthorn/vernier/pull/75

Ensures that on profile load, no threads are filtered out i.e. initialVisibleThreads contains all threads, and that the thread in which the profiler was started is the pre-selected thread i.e. it's the one and only thread in initialSelectedThreads.

Manual testing ```ruby # main thread start Vernier.profile(out: "output_main.json") do 10.times.map do |i| Thread.new do Thread.current.name = "Spawned #{i}" sleep 0.01 end end.each(&:join) end # spawned thread start 10.times.map do |i| Thread.new do if i == 5 Vernier.profile(out: "output_spawned.json") do Thread.current.name = "Spawned #{i}" sleep 0.01 end else Thread.current.name = "Spawned #{i}" sleep 0.01 end end end.each(&:join) ``` [output_main.json](https://github.com/user-attachments/files/16038921/output_main.json) [output_spawned.json](https://github.com/user-attachments/files/16038923/output_spawned.json)
jhawthorn commented 1 week ago

Thank you!