8000 print average scan/stream speed for each scanner · rubychan/coderay-scanner-tests@0222bf5 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0222bf5

Browse files
committed
print average scan/stream speed for each scanner
1 parent 72ae179 commit 0222bf5

File tree

1 file changed

+37
-11
lines changed

1 file changed

+37
-11
lines changed

coderay_suite.rb

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ def test_ALL
162162
end
163163

164164
puts 'Finished in '.green + '%0.2fs'.white % time_for_lang + '.'.green
165+
puts
165166

166167
unless @hints.empty?
167168
flunk @hints.map { |hint| ' ' + hint }.join("\n") + "\n"
@@ -178,7 +179,11 @@ def examples_test scanner, max
178179
puts "No examples found!".red
179180
else
180181
puts '%d'.yellow % examples.size + " example#{'s' if examples.size > 1} found.".green
182+
puts
181183
end
184+
185+
total_filesize = total_time_for_scanning = total_time_for_direct_streaming = 0
186+
182187
for example_filename in examples.sort
183188
@known_issue_description = @known_issue_ticket_url = nil
184189
name = File.basename(example_filename, ".#{extension}")
@@ -204,18 +209,28 @@ def examples_test scanner, max
204209

205210
if defined?(@time_for_encoding) && @time_for_encoding
206211
time_total = @time_for_scanning + @time_for_encoding
207-
print '%5.2fs'.blue % time_total
208-
print ':'.yellow + '%5.2fs'.magenta % @time_for_direct_streaming
212+
# print '%5.2fs'.blue % time_total
213+
# print ':'.yellow + '%5.2fs'.magenta % @time_for_direct_streaming
209214
if filesize > 10000 ;= 1024
210-
print ' '
211-
print '%4.0f scan'.white % [tokens.count / @time_for_scanning / 1000] + ', '.green
212-
print '%4.0f encode'.white % [tokens.count / @time_for_encoding / 1000] + ', '.green
213-
print '%4.0f sep'.blue % [tokens.count / time_total / 1000] + ', '.green
215+
print 'in kTok/s: '.white
216+
print '%4.0f scan'.yellow % [tokens.count / @time_for_scanning / 1000]
217+
print ' + '.white
218+
print '%4.0f encode'.white % [tokens.count / @time_for_encoding / 1000]
219+
print ' = '.white
220+
print '%4.0f both'.blue % [tokens.count / time_total / 1000] + ', '
214221
print '%4.0f stream'.magenta % [tokens.count / @time_for_direct_streaming / 1000]
215-
print ' (KTok/s)'.white
216-
if filesize > 5000
217-
print ' = %4.0f kB/s'.yellow % [filesize / @time_for_direct_streaming / 1000]
218-
end
222+
print ', '.green
223+
224+
print 'in kB/s: '.white
225+
print '%5.0f'.yellow % [filesize / @time_for_scanning / 1000]
226+
print ' / '.white
227+
print '%5.0f'.magenta % [filesize / @time_for_direct_streaming / 1000]
228+
229+
total_filesize += filesize
230+
total_time_for_scanning += @time_for_scanning
231+
total_time_for_direct_streaming += @time_for_direct_streaming
232+
else
233+
print 'too small'.white
219234
end
220235
@time_for_encoding = @time_for_scanning = nil
221236
end
@@ -233,6 +248,17 @@ def examples_test scanner, max
233248
end
234249
end
235250
end
251+
252+
puts
253+
254+
if total_time_for_scanning > 0 && total_time_for_direct_streaming > 0
255+
print "Average speed for #{scanner.class.title} scanner: ".green
256+
print '%0.0f'.yellow % [total_filesize / total_time_for_scanning / 1000]
257+
print ' kB/s scanning / '.white
258+
print '%0.0f'.magenta % [total_filesize / total_time_for_direct_streaming / 1000]
259+
print ' kB/s highlighting.'.white
260+
puts
261+
end
236262
end
237263
end
238264

@@ -514,7 +540,7 @@ def load_suite name
514540
suite = File.join($mydir, name, 'suite.rb')
515541
require suite
516542
rescue LoadError
517-
$stderr.puts <<-ERR
543+
puts <<-ERR
518544
519545
!! Suite #{suite} not found
520546

0 commit comments

Comments
 (0)
0