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

ruby 2.0.0 #82

Closed
shenhf opened this issue Nov 11, 2013 · 20 comments
Closed

ruby 2.0.0 #82

shenhf opened this issue Nov 11, 2013 · 20 comments

Comments

@shenhf
Copy link

shenhf commented Nov 11, 2013

CPU 100% under ruby 2.0.0, 1.9.2 works ok!

@N176CM
Copy link

N176CM commented Nov 11, 2013

I got the same problem,hope someone can fix it up....

@Empact
Copy link
Contributor

Empact commented Nov 11, 2013

Haven't seen this myself. Could you post an example script?


Sent from Mailbox for iPhone

On Sun, Nov 10, 2013 at 11:22 PM, N176CM [email protected] wrote:

I got the same problem,hope someone can fix it up....

Reply to this email directly or view it on GitHub:
#82 (comment)

@schmidp
Copy link

schmidp commented Dec 6, 2013

#!/usr/bin/env ruby

require 'rubygems'
require 'bundler/setup'
require 'roo'

ROOT_DIR = File.dirname(FILE)
INPUT = File.join(ROOT_DIR, 'data', 'CachingAlleBeobachtungen_mIV.xls')

s = Roo::Excel.new(INPUT)
p s

I have the same problem with ruby 2.0.0p247 (2013-06-27 revision 41674) [universal.x86_64-darwin13].

I cannot post the excel file in question, but it's a simple but big (6.5MB) multi sheet file containing only primitive values.

With 1.9.3 it parses instantly.

@hquick81
Copy link

hquick81 commented Jan 6, 2014

Same here with ruby 2.0.0p353

xls = Roo::Spreadsheet.open(file.path, extension: :xls) # script hangs after calling this after hitting CTRL-C the next line gives the correct output of cell 1,1
xls.cell(1,1)

@ashrocket
Copy link

It's not roo, it happens with Spreadsheet. (a dependent library)
Officially spreadsheet only supports up to 1.9.3

@N176CM
Copy link

N176CM commented Feb 3, 2014

OK.I got it------------------ 原始邮件 ------------------
发件人: "Ashley Raiteri"[email protected]
发送时间: 2014年2月3日(星期一) 晚上6:19
收件人: "Empact/roo"[email protected];
抄送: "N176CM"[email protected];
主题: Re: [roo] ruby 2.0.0 (#82)

It's not roo, it happens with Spreadsheet. (a dependent library)
Officially spreadsheet only supports up to 1.9.3


Reply to this email directly or view it on GitHub.

@kshahkshah
Copy link
Contributor

Ruby 2.1 here... unbelievably long load times for trivially small Excel spreadsheets... I'm going to try and debug...

@kshahkshah
Copy link
Contributor

RubyProf.start
spreadsheet = Roo::Excel.new("/tmp/#{spreadsheet_file_handle}.xls")

-- CTRL-C here since it takes a year and a day

result = RubyProf.stop
printer = RubyProf::FlatPrinter.new(result)
printer.print(STDOUT)

Results minus the uninteresting lines

Thread ID: 2156059640
Fiber ID: 2175658760
Total: 18.374850
Sort by: self_time

 %self      total      self      wait     child     calls  name
 21.27      3.909     3.909     0.000     0.000  2290976   Symbol#inspect
 13.13     15.293     2.412     0.000    12.881   150625  *Hash#inspect
  8.45      1.552     1.552     0.000     0.000  1269933   Fixnum#inspect
  4.68      0.859     0.859     0.000     0.000   733706   FalseClass#inspect
  4.37      1.239     0.803     0.000     0.437   177638   Array#inspect
  3.33      0.611     0.611     0.000     0.000   308485   Regexp#inspect
  1.98      0.364     0.364     0.000     0.000      272   Array#join
  1.51      0.278     0.278     0.000     0.000   123520   String#inspect
  0.99      0.182     0.182     0.000     0.001      268   Kernel#sprintf
  0.67     17.736     0.123     0.000    17.613     1882  *Hash#to_s
  0.60      0.109     0.109     0.000     0.000    89435   NilClass#inspect
  0.58      0.143     0.107     0.000     0.036     6707   Spreadsheet::Excel::Reader#get_next_chunk
  0.51     17.634     0.094     0.000    17.540     1342  *Array#to_default_s
  0.00     18.207     0.000     0.000    18.207       36  *Proc#call
  0.00     18.199     0.000     0.000    18.199     6456  *String#%
  0.00     18.367     0.000     0.000    18.367        4   IRB::Irb#signal_status
  0.00     18.040     0.000     0.000    18.040      270  *Spreadsheet::Worksheet#inspect
  0.00     17.635     0.000     0.000    17.634     1342  *Array#to_formatted_s
  0.00     18.200     0.000     0.000    18.200      284  *Array#collect
  0.00     18.375     0.000     0.000    18.375        1   RubyLex#each_top_level_statement
  0.00     18.200     0.000     0.000    18.200   123692  *Kernel#inspect
  0.00     18.200     0.000     0.000    18.200        2   IRB::Irb#output_value
  0.00     18.200     0.000     0.000    18.200        2   IRB::Context#inspect_last_value
  0.00     18.200     0.000     0.000    18.200        1   Spreadsheet::Workbook#inspect
  0.00     18.200     0.000     0.000    18.200        2   IRB::Inspector#inspect_value

@kshahkshah
Copy link
Contributor

@ashrocket yes.. I'm seeing this stem from Spreadsheet::Worksheet#inspect

    def inspect
      names = instance_variables
      names.delete '@rows'
      variables = names.collect do |name|
        "%s=%s" % [name, instance_variable_get(name)]
      end.join(' ')
      sprintf "#<%s:0x%014x %s @rows[%i]>", self.class, object_id,
                                            variables, row_count
    end

This is not roo

@kshahkshah
Copy link
Contributor

Okay... this is what's going on.. I've suspected this for a while. It's the to_s / inspect calls.

Basically if you're testing this out in IRB you implicity (thanks Ruby!) are calling inspect (or to_s?) and a bajillion objects are getting converted in order to do this for you. This is a disaster.

compare performance of a call like:
spreadsheet = Roo::Excel.new("/tmp/#{spreadsheet_file_handle}.xls").first_row
vs.

spreadsheet = Roo::Excel.new("/tmp/#{spreadsheet_file_handle}.xls")
spreadsheet.first_row

So I guess a solution is to wrap your calls in a block?

@kshahkshah
Copy link
Contributor

Yes, so I opened up the Gem and added a method, Roo::Excel#inspect

  def inspect
    to_s
  end

And it flies now... I'll submit a patch... now this kinda is in this library and not in Spreadsheet

@jordanboston
Copy link

@whistlerbrk -Has this patch been submitted and this issue essentially closed? Thanks.

@kshahkshah
Copy link
Contributor

@jordanboston this has been addressed with #115 however iirc the method I implemented needs to be implemented on the Google spreadsheet subclass as well.

It's slightly difficult to check, I am travelling at the moment.

There I also a performance issues ticket open which is possibly / likely related to and solved by this.

@thomastran
Copy link

It happens on Ruby 2.1 also. I followed hot fix of @whistlerbrk above and it works.
@whistlerbrk Could you submit a pull request for this issue?

@stevendaniels
Copy link
Contributor

If I'm not mistaken, this issue seems to affect an older version of Roo.
Roo::Base has the inspect method @whistlerbrk suggested.

This issue should probably be closed.

@pmneve
Copy link

pmneve commented Feb 12, 2015

@stevendaniels If you mean 1.13.2 that is currently the only version available through rubygems... A lot of folks who use roo would like to get the latest and have difficulty (corporate security idiocies) getting at it from github.

@stevendaniels
Copy link
Contributor

I too wish Roo would be updated on Rubygems. I created an issue (#172) that for that, but I haven't heard anything yet.

@simonoff
Copy link
Member

simonoff commented Apr 9, 2015

@pmneve you can try beta release on rubygems.

@pmneve
Copy link

pmneve commented Apr 9, 2015

@simonoff super, will do asap!

@stevendaniels
Copy link
Contributor

This issue was resolved and ver 2.0.0 of Roo is available on rubygems. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests