From: Corey Lawson Date: 2006-01-25T07:36:00+09:00 Subject: Re: slowness of WIN32OLE.rb in 1.8.2 - faster in 1.8.4? ------=_Part_2226_14869795.1138142144951 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline 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 =3D WIN32OLE.new('Excel.Application') wb =3D xl.Workbooks.open('D:\docs\corey\rubytest.xls') a =3D wb.ActiveSheet #ws.range('a1:a100').value.each { |cell| something; }; r =3D 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 th= e reference directly to the Range collection. But they're both fast enough, in that any apparent visual slowdown is in th= e 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 200= 0 & 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 wrote: > > On 1/24/06, Greg Lorriman 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 Exce= l > library (early binding), and with late binding (i.e., dim xl as object : > set > xl =3D 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 > > > > > > > > ------=_Part_2226_14869795.1138142144951--