Last active
February 8, 2019 13:43
-
-
Save andreleoni/3cdce2405f631400a6f291b760b742ad to your computer and use it in GitHub Desktop.
Benchmark sobre uso de memória Ruby Module vs Class
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
# Gem: https://github.com/SamSaffron/memory_profiler | |
##### Benchmark vendo memória de um módulo | |
require "memory_profiler" | |
MemoryProfiler.start | |
module Teste | |
extend self | |
def oi | |
"teste" | |
end | |
end | |
Teste.oi | |
report = MemoryProfiler.stop | |
report.pretty_print | |
Total allocated: 116315 bytes (1926 objects) | |
Total retained: 2606 bytes (31 objects) | |
##### Benchmark vendo memória de uma classe | |
require "memory_profiler" | |
MemoryProfiler.start | |
class Teste | |
def self.oi | |
"teste" | |
end | |
end | |
Teste.oi | |
report = MemoryProfiler.stop | |
report.pretty_print | |
Total allocated: 102987 bytes (1699 objects) | |
Total retained: 2502 bytes (29 objects) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment