WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
File tree Expand file tree Collapse file tree 3 files changed +9
-7
lines changed
Expand file tree Collapse file tree 3 files changed +9
-7
lines changed Original file line number Diff line number Diff line change 7979
8080 parsed_profile = Vernier ::ParsedProfile . read_file ( file )
8181
82- puts Vernier ::Output ::Top . new ( parsed_profile ) . output
82+ puts Vernier ::Output ::Top . new ( parsed_profile , top ) . output
8383 puts Vernier ::Output ::FileListing . new ( parsed_profile ) . output
8484 end
8585 end
Original file line number Diff line number Diff line change 33module Vernier
44 module Output
55 class Top
6- def initialize ( profile )
6+ def initialize ( profile , row_limit )
77 @profile = profile
8+ @row_limit = row_limit
89 end
910
1011 class Table
11- def initialize ( header )
12+ def initialize ( header , row_limit )
1213 @header = header
1314 @rows = [ ]
15+ @row_limit = row_limit
1416 yield self
1517 end
1618
@@ -24,7 +26,7 @@ def to_s
2426 row_separator ,
2527 format_row ( @header ) ,
2628 row_separator
27- ] + @rows . map do |row |
29+ ] + @rows . first ( @row_limit ) . map do |row |
2830 format_row ( row )
2931 end + [ row_separator ]
3032 ) . join ( "\n " )
@@ -70,7 +72,7 @@ def output
7072 top_by_self [ name ] += weight
7173 end
7274
73- Table . new %w[ Samples % name ] do |t |
75+ Table . new %w[ Samples % name ] , @row_limit do |t |
7476 top_by_self . sort_by ( &:last ) . reverse . each do |frame , samples |
7577 pct = 100.0 * samples / total
7678 t << [ samples . to_s , pct . round ( 1 ) . to_s , frame ]
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ def test_complex_profile
2222 end
2323 end
2424
25- output = Vernier ::Output ::Top . new ( result ) . output
25+ output = Vernier ::Output ::Top . new ( result , 20 ) . output
2626 assert_match ( /^| \d + *\| \d +\. \d *\| GVLTest\. sleep_without_gvl *\| $/ , output )
2727 assert_match ( /^| \d + *\| \d +\. \d *\| GVLTest\. sleep_holding_gvl *\| $/ , output )
2828 assert_match ( /^| \d + *\| \d +\. \d *\| Kernel#sleep *\| $/ , output )
@@ -31,7 +31,7 @@ def test_complex_profile
3131
3232 def test_parsed_profile
3333 profile = Vernier ::ParsedProfile . read_file ( fixture_path ( "gvl_sleep.vernier.json" ) )
34- output = Vernier ::Output ::Top . new ( profile ) . output
34+ output = Vernier ::Output ::Top . new ( profile , 20 ) . output
3535 assert_includes output , "| 2013 | 24.8 | GVLTest.sleep_holding_gvl"
3636 assert_includes output , "| 2010 | 24.7 | Kernel#sleep"
3737 assert_includes output , "| 2010 | 24.7 | GVLTest.sleep_without_gvl"
You can’t perform that action at this time.
0 commit comments