Class: Flydata::Mysql::MysqlDumpParser::InsertParser

Inherits:
Object
  • Object
show all
Defined in:
lib/flydata/command/sync.rb

Defined Under Namespace

Modules: State

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ InsertParser

Returns a new instance of InsertParser.



878
879
880
881
882
# File 'lib/flydata/command/sync.rb', line 878

def initialize(file)
  @file = file
  @values = []
  @values_set = []
end

Instance Method Details

#parseObject



898
899
900
901
902
903
904
905
906
907
908
# File 'lib/flydata/command/sync.rb', line 898

def parse
  start_ruby_prof
  bench_start_time = Time.now
  target_line = @file.readline
  _parse(target_line)
ensure
  stop_ruby_prof
  if ENV['FLYDATA_BENCHMARK']
    puts " -> time:#{Time.now.to_f - bench_start_time.to_f} size:#{target_line.size}"
  end
end

#start_ruby_profObject



884
885
886
# File 'lib/flydata/command/sync.rb', line 884

def start_ruby_prof
  RubyProf.start if defined?(RubyProf) and not RubyProf.running?
end

#stop_ruby_profObject



888
889
890
891
892
893
894
895
896
# File 'lib/flydata/command/sync.rb', line 888

def stop_ruby_prof
  if defined?(RubyProf) and RubyProf.running?
    result = RubyProf.stop
    #printer = RubyProf::GraphPrinter.new(result)
    printer = RubyProf::GraphHtmlPrinter.new(result)
    #printer.print(STDOUT)
    printer.print(File.new("ruby-prof-out-#{Time.now.to_i}.html", "w"), :min_percent => 3)
  end
end