Skip to content

Commit

Permalink
Añadido el Benchmark y Coveralls
Browse files Browse the repository at this point in the history
  • Loading branch information
alu0101061672 committed Dec 19, 2018
1 parent ba50247 commit 087496a
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 367 deletions.
1 change: 1 addition & 0 deletions .coveralls.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
service_name: travis-ci
33 changes: 33 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,16 @@ GEM
remote: https://rubygems.org/
specs:
coderay (1.1.2)
coveralls (0.7.1)
multi_json (~> 1.3)
rest-client
simplecov (>= 0.7)
term-ansicolor
thor
diff-lcs (1.3)
docile (1.3.1)
domain_name (0.5.20180417)
unf (>= 0.0.5, < 1.0.0)
ffi (1.9.25)
formatador (0.2.5)
guard (2.15.0)
Expand All @@ -28,13 +37,21 @@ GEM
guard (~> 2.1)
guard-compat (~> 1.1)
rspec (>= 2.99.0, < 4.0)
http-cookie (1.0.3)
domain_name (~> 0.5)
json (2.1.0)
listen (3.1.5)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
ruby_dep (~> 1.2)
lumberjack (1.0.13)
method_source (0.9.2)
mime-types (3.2.2)
mime-types-data (~> 3.2015)
mime-types-data (3.2018.0812)
multi_json (1.13.1)
nenv (0.3.0)
netrc (0.11.0)
notiffany (0.1.1)
nenv (~> 0.1)
shellany (~> 0.0)
Expand All @@ -45,6 +62,10 @@ GEM
rb-fsevent (0.10.3)
rb-inotify (0.9.10)
ffi (>= 0.5.0, < 2)
rest-client (2.0.2)
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 4.0)
netrc (~> 0.8)
rspec (3.8.0)
rspec-core (~> 3.8.0)
rspec-expectations (~> 3.8.0)
Expand All @@ -60,13 +81,25 @@ GEM
rspec-support (3.8.0)
ruby_dep (1.5.0)
shellany (0.0.1)
simplecov (0.16.1)
docile (~> 1.1)
json (>= 1.8, < 3)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.2)
term-ansicolor (1.7.0)
tins (~> 1.0)
thor (0.20.3)
tins (1.20.2)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.5)

PLATFORMS
ruby

DEPENDENCIES
bundler (~> 1.16)
coveralls
guard
guard-bundler
guard-rspec
Expand Down
11 changes: 11 additions & 0 deletions lib/prct06/persona.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,16 @@ def <=>(other)

end

def <=>(other)

return self.IMC <=> other.IMC

end

def <=>(other)

return self.gasto_energetico_total <=> other.gasto_energetico_total

end

end
2 changes: 1 addition & 1 deletion prct06.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ Gem::Specification.new do |spec|
spec.add_development_dependency "guard"
spec.add_development_dependency "guard-rspec"
spec.add_development_dependency "guard-bundler"

spec.add_development_dependency "coveralls"
end
Binary file removed spec/.prct06_spec.rb.swp
Binary file not shown.
12 changes: 6 additions & 6 deletions spec/persona_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@
@lista.insert_end(@pa1)
@lista.insert_end(@pa2)

expect(@lista.max {|a,b| a.IMC <=> b.IMC } ).to eq(@pa2)
expect(@lista.max {|a,b| a.nombre <=> b.nombre } ).to eq(@pa2)
expect(@lista.max {|a,b| a.IMC <=> b.IMC } ).to eq(@pa1)
expect(@lista.max {|a,b| a.nombre <=> b.nombre } ).to eq(@pa1)


end
Expand All @@ -216,8 +216,8 @@
@lista.insert_end(@pa1)
@lista.insert_end(@pa2)

expect(@lista.min {|a,b| a.IMC <=> b.IMC } ).to eq(@pa1)
expect(@lista.min {|a,b| a.nombre <=> b.nombre } ).to eq(@pa1)
expect(@lista.min {|a,b| a.IMC <=> b.IMC } ).to eq(@pa2)
expect(@lista.min {|a,b| a.nombre <=> b.nombre } ).to eq(@pa2)
# expect(@lista.min {|c,d| c.RCC <=> d.RCC } ).to eq(@pa2)


Expand All @@ -228,8 +228,8 @@
@lista.insert_end(@pa1)
@lista.insert_end(@pa2)

expect(@lista.sort {|a,b| a.IMC <=> b.IMC } ).to eq([@pa1,@pa2])
expect(@lista.sort {|a,b| a.nombre <=> b.nombre } ).to eq([@pa1,@pa2])
expect(@lista.sort {|a,b| a.IMC <=> b.IMC } ).to eq([@pa2,@pa1])
expect(@lista.sort {|a,b| a.nombre <=> b.nombre } ).to eq([@pa2,@pa1])
#expect(@lista.sort {|a,b| a.RCC <=> b.RCC } ).to eq([@pa2,@pa1])


Expand Down
111 changes: 0 additions & 111 deletions spec/persona_spec.rb.save

This file was deleted.

17 changes: 15 additions & 2 deletions spec/prct06_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require 'benchmark'

RSpec.describe Prct06 do
it "has a version number" do
expect(Prct06::VERSION).not_to be nil
Expand Down Expand Up @@ -333,6 +335,13 @@
expect(@vector_menus.caso_each).to eq([718.34, 1271.06, 1516.4, 1869.3, 2056.58, 2064.5, 2617.22, 2862.56, 2862.56, 2970.12])
expect(@vector_menus.sort { |a,b| a <=> b }).to eq([718.34, 1271.06, 1516.4, 1869.3, 2056.58, 2064.5, 2617.22, 2862.56, 2862.56, 2970.12])

n = 50000

Benchmark.bm do |x|
x.report("for array:") {n.times do @vector_menus.buclefor; end}
x.report("each array:"){n.times do @vector_menus.caso_each; end}
x.report("sort array:"){n.times do @vector_menus.sort { |a,b| a <=> b } ; end}
end

end

Expand All @@ -355,9 +364,13 @@
expect(@listapa.convertir_array_each).to eq([1454.255, 1642.63, 1743.38, 1757.25, 1951.125, 2102.375, 2202.11, 2240.53, 2560.86, 2961.75])
expect(@listapa.sort { |a,b| a <=> b }).to eq([1454.255, 1642.63, 1743.38, 1757.25, 1951.125, 2102.375, 2202.11, 2240.53, 2560.86, 2961.75])

n = 50000



Benchmark.bm do |x|
x.report("for lista:") {n.times do @listapa.convertir_array_for; end}
x.report("each lista:"){n.times do @listapa.convertir_array_each; end}
x.report("sort lista:"){n.times do @listapa.sort { |a,b| a <=> b } ; end}
end
end


Expand Down
Loading

0 comments on commit 087496a

Please sign in to comment.