weixin_39562197
2020-11-25 20:54 阅读 0

Speed up writing

As discussed via email, I'd like to submit these patches for inclusion upstream.

They greatly reduce the time it takes to write workbooks, especially ones with a large number of cells.

In my test script, measuring the previously released stable version of the gem:


$ ./make_book.rb 
Mon Jun 11 12:16:12 -0400 2012 Populating
Mon Jun 11 12:16:13 -0400 2012 Populated 25056 rows
Mon Jun 11 12:16:13 -0400 2012 Writing
Mon Jun 11 12:21:55 -0400 2012 Done
Mon Jun 11 12:21:55 -0400 2012 writing done in 341.704384088516 seconds

After my changes:


$ ./make_book.rb 
Mon Jun 11 12:22:02 -0400 2012 Populating
Mon Jun 11 12:22:03 -0400 2012 Populated 25056 rows
Mon Jun 11 12:22:03 -0400 2012 Writing
Mon Jun 11 12:22:16 -0400 2012 Done
Mon Jun 11 12:22:16 -0400 2012 writing done in 13.5842142105103 seconds

该提问来源于开源项目:zdavatz/spreadsheet

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

7条回答 默认 最新

  • weixin_39641876 weixin_39641876 2020-11-25 20:54

    Dear Mina

    This looks almost all good except that running

    ruby test/suite.rb

    results in the following error when run with Ruby 1.8 and Ruby 1.9.

    Running tests:

    ......E.............................................................

    Finished tests in 0.799693s, 85.0326 tests/s, 1287.9936 assertions/s.

    1) Error: test_write_fonts(Spreadsheet::Excel::Writer::TestWorkbook): ArgumentError: wrong number of arguments (3 for 0) /home/zeno/.software/spreadsheet/test/excel/writer/workbook.rb:59:in block in test_write_fonts' /home/zeno/.software/spreadsheet/lib/spreadsheet/excel/writer/workbook.rb:362:inblock in write_fonts' /home/zeno/.software/spreadsheet/lib/spreadsheet/excel/writer/workbook.rb:359:in each' /home/zeno/.software/spreadsheet/lib/spreadsheet/excel/writer/workbook.rb:359:inwrite_fonts' /home/zeno/.software/spreadsheet/test/excel/writer/workbook.rb:65:in `test_write_fonts'

    Can you fix this please, and I will pull the changes and test again. If all is fine I will release the new gem after that.

    Best Zeno

    点赞 评论 复制链接分享
  • weixin_39562197 weixin_39562197 2020-11-25 20:54

    Interesting. The test suite runs successfully on my end:

    
    $ ruby -v
    ruby 1.8.7 (2012-02-08 patchlevel 358) [i686-darwin10]
    

    I'll investigate some more.

    点赞 评论 复制链接分享
  • weixin_39562197 weixin_39562197 2020-11-25 20:54

    Ok, I was able to replicate it on ruby 1.9

    点赞 评论 复制链接分享
  • weixin_39562197 weixin_39562197 2020-11-25 20:54

    And voila. Fixed in 28dd192ddb8fc8c16ff38c9c8445b829ef652cdb

    点赞 评论 复制链接分享
  • weixin_39630410 weixin_39630410 2020-11-25 20:54

    Hi mina, could you share the make_book.rb that you used to test the speed of writing?

    点赞 评论 复制链接分享
  • weixin_39562197 weixin_39562197 2020-11-25 20:54

    Hi Paco

    Unfortunately I can't find it.

    IIRC it was just a loop writing a few thousand rows of similar nature (couple of header columns, few metric columns).

    点赞 评论 复制链接分享
  • weixin_39630410 weixin_39630410 2020-11-25 20:54

    Hi Mina,

    don't worries, I didn't get that reduction of 20x but I got better performance

    Thanks for the work

    点赞 评论 复制链接分享

相关推荐