Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Continuous insertion buffering #194

Merged
merged 1 commit into from
Oct 31, 2020
Merged

Conversation

aycabta
Copy link
Member

@aycabta aycabta commented Oct 31, 2020

The rendering time in IRB has been reduced as follows:

start = Time.now

[{"_id"=>"5f9072a4589a06d2d74b6028",
  "index"=>0,
  "guid"=>"6b3051e2-dbc7-4537-bdb9-6cd7bb5358a7",
  "isActive"=>true,
  "balance"=>"$1,442.84",
  "picture"=>"http://placehold.it/32x32",
  "age"=>34,
  "eyeColor"=>"blue",
  "name"=>{"first"=>"Ward", "last"=>"Levy"},
  "company"=>"HYPLEX",
  "email"=>"[email protected]",
  "phone"=>"+1 (867) 568-3319",
  "address"=>"867 Cobek Court, Clara, Maryland, 3254",
  "about"=>
   "Exercitation eu ex aliqua sit. Pariatur aliquip incididunt sint id non consectetur ullamco Lorem ea mollit duis amet sint labore. Commodo laborum labore commodo officia in cillum adipisicing esse excepteur cupidatat adipisicing ut. Non esse incididunt voluptate aliquip cillum eu aute duis laboris sit et. Amet enim quis tempor occaecat excepteur exercitation excepteur deserunt amet cillum adipisicing.",
  "registered"=>"Monday, May 25, 2015 6:51 AM",
  "latitude"=>"16.001127",
  "longitude"=>"-72.377848",
  "tags"=>["dolore", "nostrud", "occaecat", "cillum", "nisi"],
  "range"=>[0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
  "friends"=>
   [{"id"=>0, "name"=>"Alison Bryant"},
    {"id"=>1, "name"=>"Ester Espinoza"},
    {"id"=>2, "name"=>"Sullivan Kane"}],
  "greeting"=>"Hello, Ward! You have 7 unread messages.",
  "favoriteFruit"=>"apple"}]

puts "Duration: #{Time.now - start} seconds"

2.17sec -> 0.92sec

start = Time.now

"Exercitation eu ex aliqua sit. Pariatur aliquip incididunt sint id non consectetur ullamco Lorem ea mollit duis amet sint labore. Commodo laborum labore commodo officia in cillum adipisicing esse excepteur cupidatat adipisicing ut. Non esse incididunt voluptate aliquip cillum eu aute duis laboris sit et. Amet enim quis tempor occaecat excepteur exercitation excepteur deserunt amet cillum adipisicing."

puts "Duration: #{Time.now - start} seconds"

1.57sec -> 0.22sec

start = Time.now

def each_top_level_statement
  initialize_input
  catch(:TERM_INPUT) do
    loop do
      begin
        prompt
        unless l = lex
          throw :TERM_INPUT if @line == ''
        else
          @line_no += l.count("\n")
          next if l == "\n"
          @line.concat l
          if @code_block_open or @ltype or @continue or @indent > 0
            next
          end
        end
        if @line != "\n"
          @line.force_encoding(@io.encoding)
          yield @line, @exp_line_no
        end
        break if @io.eof?
        @line = ''
        @exp_line_no = @line_no

        @indent = 0
      rescue TerminateLineInput
        initialize_input
        prompt
      end
    end
  end
end

puts "Duration: #{Time.now - start} seconds"

0.88sec -> 0.77sec

ref. ruby/irb#43

The rendering time in IRB has been reduced as follows:

  start = Time.now

  [{"_id"=>"5f9072a4589a06d2d74b6028",
    "index"=>0,
    "guid"=>"6b3051e2-dbc7-4537-bdb9-6cd7bb5358a7",
    "isActive"=>true,
    "balance"=>"$1,442.84",
    "picture"=>"http://placehold.it/32x32",
    "age"=>34,
    "eyeColor"=>"blue",
    "name"=>{"first"=>"Ward", "last"=>"Levy"},
    "company"=>"HYPLEX",
    "email"=>"[email protected]",
    "phone"=>"+1 (867) 568-3319",
    "address"=>"867 Cobek Court, Clara, Maryland, 3254",
    "about"=>
     "Exercitation eu ex aliqua sit. Pariatur aliquip incididunt sint id non consectetur ullamco Lorem ea mollit duis amet sint labore. Commodo laborum labore commodo officia in cillum adipisicing esse excepteur cupidatat adipisicing ut. Non esse incididunt voluptate aliquip cillum eu aute duis laboris sit et. Amet enim quis tempor occaecat excepteur exercitation excepteur deserunt amet cillum adipisicing.",
    "registered"=>"Monday, May 25, 2015 6:51 AM",
    "latitude"=>"16.001127",
    "longitude"=>"-72.377848",
    "tags"=>["dolore", "nostrud", "occaecat", "cillum", "nisi"],
    "range"=>[0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
    "friends"=>
     [{"id"=>0, "name"=>"Alison Bryant"},
      {"id"=>1, "name"=>"Ester Espinoza"},
      {"id"=>2, "name"=>"Sullivan Kane"}],
    "greeting"=>"Hello, Ward! You have 7 unread messages.",
    "favoriteFruit"=>"apple"}]

  puts "Duration: #{Time.now - start} seconds"

2.17sec -> 0.92sec

  start = Time.now

  "Exercitation eu ex aliqua sit. Pariatur aliquip incididunt sint id non consectetur ullamco Lorem ea mollit duis amet sint labore. Commodo laborum labore commodo officia in cillum adipisicing esse excepteur cupidatat adipisicing ut. Non esse incididunt voluptate aliquip cillum eu aute duis laboris sit et. Amet enim quis tempor occaecat excepteur exercitation excepteur deserunt amet cillum adipisicing."

  puts "Duration: #{Time.now - start} seconds"

1.57sec -> 0.22sec

  start = Time.now

  def each_top_level_statement
    initialize_input
    catch(:TERM_INPUT) do
      loop do
        begin
          prompt
          unless l = lex
            throw :TERM_INPUT if @line == ''
          else
            @line_no += l.count("\n")
            next if l == "\n"
            @line.concat l
            if @code_block_open or @ltype or @continue or @indent > 0
              next
            end
          end
          if @line != "\n"
            @line.force_encoding(@io.encoding)
            yield @line, @exp_line_no
          end
          break if @io.eof?
          @line = ''
          @exp_line_no = @line_no

          @indent = 0
        rescue TerminateLineInput
          initialize_input
          prompt
        end
      end
    end
  end

  puts "Duration: #{Time.now - start} seconds"

0.88sec -> 0.77sec
@aycabta aycabta merged commit cd9bbff into ruby:master Oct 31, 2020
@aycabta aycabta deleted the insertion-buffering branch October 31, 2020 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant