Created
September 21, 2018 18:03
-
-
Save ohaddahan/f59aa5a261cb56e7b1ca96fb97a8e3fb to your computer and use it in GitHub Desktop.
This file contains hidden or 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
Warming up -------------------------------------- | |
dump : 136.247k i/100ms | |
dump2 : 209.935k i/100ms | |
Calculating ------------------------------------- | |
dump : 2.095M (± 3.3%) i/s - 10.491M in 5.013742s | |
dump2 : 4.570M (± 5.9%) i/s - 22.883M in 5.032849s | |
Comparison: | |
dump2 :: 4570234.5 i/s | |
dump :: 2094819.0 i/s - 2.18x slower |
This file contains hidden or 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
require 'benchmark/ips' | |
def dump(value, **options) | |
dump_to_io(value, **options) | |
end | |
def dump_to_io(value, compress_threshold: nil) | |
end | |
def dump2(value, compress_threshold: nil) | |
dump_to_io2(value, compress_threshold: compress_threshold) | |
end | |
def dump_to_io2(value, compress_threshold: nil) | |
end | |
require 'memory_profiler' | |
MemoryProfiler.report { dump(nil) }.pretty_print(to_file: 'report_dump.txt') | |
MemoryProfiler.report { dump2(nil) }.pretty_print(to_file: 'report_dump2.txt') | |
Benchmark.ips do |x| | |
x.config(time: 5, warmup: 1) | |
x.report("dump :") { dump(nil) } | |
x.report("dump2 :") { dump2(nil) } | |
x.compare! | |
end |
This file contains hidden or 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
Total allocated: 80 bytes (2 objects) | |
Total retained: 0 bytes (0 objects) | |
allocated memory by gem | |
----------------------------------- | |
80 other | |
allocated memory by file | |
----------------------------------- | |
80 (irb) | |
allocated memory by location | |
----------------------------------- | |
40 (irb):84 | |
40 (irb):98 | |
allocated memory by class | |
----------------------------------- | |
80 Hash | |
allocated objects by gem | |
----------------------------------- | |
2 other | |
allocated objects by file | |
----------------------------------- | |
2 (irb) | |
allocated objects by location | |
----------------------------------- | |
1 (irb):84 | |
1 (irb):98 | |
allocated objects by class | |
----------------------------------- | |
2 Hash | |
retained memory by gem | |
----------------------------------- | |
NO DATA | |
retained memory by file | |
----------------------------------- | |
NO DATA | |
retained memory by location | |
----------------------------------- | |
NO DATA | |
retained memory by class | |
----------------------------------- | |
NO DATA | |
retained objects by gem | |
----------------------------------- | |
NO DATA | |
retained objects by file | |
----------------------------------- | |
NO DATA | |
retained objects by location | |
----------------------------------- | |
NO DATA | |
retained objects by class | |
----------------------------------- | |
NO DATA | |
Allocated String Report | |
----------------------------------- | |
Retained String Report | |
----------------------------------- |
This file contains hidden or 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
Total allocated: 0 bytes (0 objects) | |
Total retained: 0 bytes (0 objects) | |
allocated memory by gem | |
----------------------------------- | |
NO DATA | |
allocated memory by file | |
----------------------------------- | |
NO DATA | |
allocated memory by location | |
----------------------------------- | |
NO DATA | |
allocated memory by class | |
----------------------------------- | |
NO DATA | |
allocated objects by gem | |
----------------------------------- | |
NO DATA | |
allocated objects by file | |
----------------------------------- | |
NO DATA | |
allocated objects by location | |
----------------------------------- | |
NO DATA | |
allocated objects by class | |
----------------------------------- | |
NO DATA | |
retained memory by gem | |
----------------------------------- | |
NO DATA | |
retained memory by file | |
----------------------------------- | |
NO DATA | |
retained memory by location | |
----------------------------------- | |
NO DATA | |
retained memory by class | |
----------------------------------- | |
NO DATA | |
retained objects by gem | |
----------------------------------- | |
NO DATA | |
retained objects by file | |
----------------------------------- | |
NO DATA | |
retained objects by location | |
----------------------------------- | |
NO DATA | |
retained objects by class | |
----------------------------------- | |
NO DATA | |
Allocated String Report | |
----------------------------------- | |
Retained String Report | |
----------------------------------- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment