null+****@clear*****
null+****@clear*****
2011年 1月 10日 (月) 19:21:36 JST
Kouhei Sutou 2011-01-10 10:21:36 +0000 (Mon, 10 Jan 2011)
New Revision: 97969db51277ac8ca7099f86606a4505760af87b
Log:
add --report-progress option.
Modified files:
tools/groonga-check-memory-leak.rb
Modified: tools/groonga-check-memory-leak.rb (+11 -0)
===================================================================
--- tools/groonga-check-memory-leak.rb 2011-01-10 08:44:27 +0000 (cc8af86)
+++ tools/groonga-check-memory-leak.rb 2011-01-10 10:21:36 +0000 (c5ac6c9)
@@ -13,6 +13,7 @@ require 'stringio'
options = OpenStruct.new
options.groonga = "groonga"
options.show_result = false
+options.report_progress = true
option_parser = OptionParser.new do |parser|
parser.banner += " DATABASE COMMAND_FILE1 ..."
@@ -26,6 +27,11 @@ option_parser = OptionParser.new do |parser|
"Show result of command") do |boolean|
options.show_result = boolean
end
+
+ parser.on("--[no-]report-progress",
+ "Report progress") do |boolean|
+ options.report_progress = boolean
+ end
end
database, *command_files = option_parser.parse!(ARGV)
@@ -34,9 +40,14 @@ if database.nil?
exit(false)
end
+i = 0
command_files.each do |path|
File.open(path) do |file|
file.each_line do |command|
+ if options.report_progress
+ i += 1
+ puts("#{i} commands done.") if (i / 1000).zero?
+ end
command = command.chomp
base_name = File.basename($0, ".*")
log = Tempfile.new("#{base_name}-log")