Corey Lawson
1/24/2006 10:36:00 PM
What is slow, though? In Ruby 1.8.2, with a workbook with one sheet with
1000 cell values (pop'd with Random() *1000 values), I get pretty snappy
performance:
require 'win32ole'
xl = WIN32OLE.new('Excel.Application')
wb = xl.Workbooks.open('D:\docs\corey\rubytest.xls')
a = wb.ActiveSheet
#ws.range('a1:a100').value.each { |cell| something; };
r = a.range('b1:b1000')
#both of these work pretty dang fast for me:
r.value.each do |c|
#do something
end
and
r.each.value do |c|
#do something
end
even:
a.range('B1:B1000').each do |c|
print c.value
end
...is still pretty fast, but probably only 60-70% of doing the loop with the
reference directly to the Range collection.
But they're both fast enough, in that any apparent visual slowdown is in the
console output, not in the actual loop or dealing with transfers between
Excel & Ruby thru Win32OLE.
But I have 1100 MB RAM (and only an Athlon 1400 processor), using Excel 2000
& Win2000 SP4. Is your computer RAM-limited?
I have 2x512MB sticks, so I'm not going to pull any out to test with less
RAM...
On 1/24/06, Corey Lawson <corey.ssf.lawson@gmail.com> wrote:
>
> On 1/24/06, Greg Lorriman <temp@lorriman.com> wrote:
> >
> > Its not enough 'though; the performance problem in 1.8.2 is of
> > elephantine proportions. Someone here also suggested, some time ago,
> > that WIN32OLE has 100% cpu usage even when idle?!? Was that a hoax (I
> > haven't tried testing for that)? That might go some way to explaining
> > my problems.
>
>
> Well, I'm not seeing it. I'm messing around with ADO thru WIN32OLE in an
> IRB
> session, and it's been holding the ADO connection open for a few days now,
> and it's not running a load higher than the usual Windows 2000 background
> noise.
>
> Which version of Excel are you using?
>
> Have you compared your ruby scripts with the same code in (barf) VBScript?
>
> Ruby fakes early binding, but it's still doing late binding, vis a vis
> Visual Basic. Try out your VB code with an explicit reference to the Excel
> library (early binding), and with late binding (i.e., dim xl as object :
> set
> xl = CreateObject("Excel.Application")) and see if there's a difference,
> because there should be.
>
> Anyone one else experiencing this, apart from the odd posts to this
> > group from the past?
> >
> > Greg
> >
> >
> >
>
>