Skip to content

Commit

Permalink
Performance tests #389
Browse files Browse the repository at this point in the history
  • Loading branch information
IanTrudel committed Nov 21, 2017
1 parent 980149c commit b904b22
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Tests/performance/brownian.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
NUMBER_OF_SHAPES = 192

Shoes.app do
@shapes = []

NUMBER_OF_SHAPES.times do
fill rgb(rand(255), rand(255), rand(255))
@shapes << oval(rand(self.width), rand(self.height), rand(100))
end

animate(60) do
@shapes.each do |shape|
mx = rand > 0.5 ? +1 : -1
my = rand > 0.5 ? +1 : -1
shape.move shape.left + mx, shape.top + my
end
end
end
7 changes: 7 additions & 0 deletions Tests/performance/buttons.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
NUMBER_OF_BUTTONS = 2000

Shoes.app do
NUMBER_OF_BUTTONS.times do |n|
button "[#{n}]"
end
end
17 changes: 17 additions & 0 deletions Tests/performance/counters.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
NUMBER_OF_COUNTERS = 150
FPS = 24

Shoes.app do
@counter = []
@text = []
NUMBER_OF_COUNTERS.times do |n|
@counter << Time.now
@text << para
animate(FPS) do |frames|
if (0 == (frames % FPS))
@text[n].text = "FPS #{ FPS / ((frames >= FPS) ? (Time.now - @counter[n]) : 1.0)}\n"
@counter[n] = Time.now
end
end
end
end
26 changes: 26 additions & 0 deletions Tests/performance/magic_show.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
IMAGES = [
"shoes-icon.png",
"shoes-icon-blue.png",
"shoes-icon-federales.png",
"shoes-icon-red.png"
]

NUMBER_OF_IMAGES = 117

Shoes.app do
@images = []
@interpolator = (tmp = (0..50).collect { |n| -n }) + tmp.reverse

NUMBER_OF_IMAGES.times do
@images << image("#{DIR}/static/#{IMAGES.sample}")
end

@counter = 1
animate(@fps = 60) do |frame|
@images.each { |img| img.rotate(@interpolator.first) }
if ((frame / @fps) == @counter)
@counter += 1
@interpolator.push @interpolator.shift
end
end
end

0 comments on commit b904b22

Please sign in to comment.