-
Notifications
You must be signed in to change notification settings - Fork 503
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Inherit Roo::Excelx::Coordinate from Array
Profiling Script ``` MemoryProfiler.report{ Roo::Excelx.new(file_name).tap{|x|(2..x.last_row).each{|i| x.row(i)}} }.pretty_print ``` Master: ``` Total allocated: 34559100 bytes (504994 objects) Total retained: 5563403 bytes (103022 objects) allocated memory by gem ----------------------------------- 19254338 roo/lib 8509100 nokogiri-1.8.4 6793822 rubyzip-1.2.2 1304 tmpdir 320 weakref 216 other allocated objects by gem ----------------------------------- 358381 roo/lib 145846 nokogiri-1.8.4 735 rubyzip-1.2.2 22 tmpdir 8 weakref 2 other retained memory by gem ----------------------------------- 5561094 roo/lib 792 rubyzip-1.2.2 725 nokogiri-1.8.4 320 weakref 296 tmpdir 176 other retained objects by gem ----------------------------------- 102989 roo/lib 14 nokogiri-1.8.4 8 weakref 7 rubyzip-1.2.2 3 tmpdir 1 other ``` After Patch: ``` Total allocated: 33439850 bytes (477013 objects) Total retained: 4444153 bytes (75041 objects) allocated memory by gem ----------------------------------- 18135098 roo/lib 8509100 nokogiri-1.8.4 6793812 rubyzip-1.2.2 1304 tmpdir 320 weakref 216 other allocated objects by gem ----------------------------------- 330400 roo/lib 145846 nokogiri-1.8.4 735 rubyzip-1.2.2 22 tmpdir 8 weakref 2 other retained memory by gem ----------------------------------- 4441854 roo/lib 782 rubyzip-1.2.2 725 nokogiri-1.8.4 320 weakref 296 tmpdir 176 other retained objects by gem ----------------------------------- 75008 roo/lib 14 nokogiri-1.8.4 8 weakref 7 rubyzip-1.2.2 3 tmpdir 1 other ```
- Loading branch information
1 parent
bd0b0f8
commit 00356c2
Showing
5 changed files
with
78 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# frozen_string_literal: true | ||
|
||
require "test_helper" | ||
|
||
class TestRooExcelxCoordinate < Minitest::Test | ||
def row | ||
10 | ||
end | ||
|
||
def column | ||
20 | ||
end | ||
|
||
def coordinate | ||
Roo::Excelx::Coordinate.new(row, column) | ||
end | ||
|
||
def array | ||
[row, column] | ||
end | ||
|
||
def test_row | ||
assert_same row, coordinate.row | ||
end | ||
|
||
def test_column | ||
assert_same column, coordinate.column | ||
end | ||
|
||
def test_frozen? | ||
assert coordinate.frozen? | ||
end | ||
|
||
def test_equality | ||
hash = {} | ||
hash[coordinate] = true | ||
assert hash.key?(coordinate) | ||
assert hash.key?(array) | ||
end | ||
|
||
def test_expand | ||
r, c = coordinate | ||
assert_same row, r | ||
assert_same column, c | ||
end | ||
|
||
def test_aref | ||
assert_same row, coordinate[0] | ||
assert_same column, coordinate[1] | ||
end | ||
end |