Permalink
Browse files

Add simple performance suite

Run "make perf"
  • Loading branch information...
Koen Bok
Koen Bok committed Dec 10, 2015
1 parent d443397 commit cfb7d76b0150322fd362ceb9e407bc9893aff63e
Showing with 966 additions and 0 deletions.
  1. +3 −0 Makefile
  2. +36 −0 extras/Perf.framer/.gitignore
  3. +138 −0 extras/Perf.framer/app.coffee
  4. +2 −0 extras/Perf.framer/app.js
  5. 0 extras/{Studio.framer → Perf.framer}/framer/coffee-script.js
  6. 0 extras/{Studio.framer → Perf.framer}/framer/config.json
  7. 0 extras/{Studio.framer/framer/framer.js → Perf.framer/framer/framer.debug.js}
  8. 0 extras/{Studio.framer → Perf.framer}/framer/framer.debug.js.map
  9. +762 −0 extras/Perf.framer/framer/framer.generated.js
  10. 0 extras/{Studio.framer → Perf.framer}/framer/framer.init.js
  11. +1 −0 extras/Perf.framer/framer/framer.js
  12. 0 extras/{Studio.framer → Perf.framer}/framer/framer.js.map
  13. +12 −0 extras/Perf.framer/framer/framer.modules.js
  14. BIN extras/Perf.framer/framer/images/background.png
  15. BIN extras/Perf.framer/framer/images/cursor-active.png
  16. BIN extras/Perf.framer/framer/images/cursor-active@2x.png
  17. BIN extras/{Studio.framer → Perf.framer}/framer/images/cursor.png
  18. BIN extras/{Studio.framer → Perf.framer}/framer/images/cursor@2x.png
  19. BIN extras/Perf.framer/framer/images/icon-120.png
  20. BIN extras/Perf.framer/framer/images/icon-152.png
  21. BIN extras/Perf.framer/framer/images/icon-76.png
  22. BIN extras/Perf.framer/framer/images/icon-arrow.png
  23. BIN extras/Perf.framer/framer/images/icon-arrow@2x.png
  24. BIN extras/Perf.framer/framer/images/icon-close.png
  25. BIN extras/Perf.framer/framer/images/icon-close@2x.png
  26. BIN extras/Perf.framer/framer/images/icon-framer.png
  27. BIN extras/Perf.framer/framer/images/icon-framer@2x.png
  28. BIN extras/Perf.framer/framer/images/icon-share.png
  29. BIN extras/Perf.framer/framer/images/icon-share@2x.png
  30. 0 extras/{Studio.framer → Perf.framer}/framer/mirror.css
  31. 0 extras/{Studio.framer → Perf.framer}/framer/style.css
  32. 0 extras/{Studio.framer → Perf.framer}/framer/version
  33. 0 extras/Perf.framer/images/.gitkeep
  34. +2 −0 extras/{Studio.framer → Perf.framer}/index.html
  35. +10 −0 extras/Perf.framer/modules/myModule.coffee
View
@@ -43,6 +43,9 @@ coverage: bootstrap
studio:
open -a "Framer Studio" extras/Studio.framer
perf:
open -a "Framer Studio" extras/Perf.framer
# Building and uploading the site
dist:
@@ -0,0 +1,36 @@
# Framer Git Ignore
# General OSX
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
# Framer Specific
.temp.html
framer/*.old.*
framer/backup.coffee
framer/backups/*
framer/.*.hash
@@ -0,0 +1,138 @@
class FPS
constructor: ->
@start()
start: ->
@_start = Utils.getTime()
@_time = @_start
@_frames = []
Framer.Loop.on("update", @tick)
stop: ->
Framer.Loop.off("update", @tick)
tick: =>
now = Utils.getTime()
@_frames.push(now - @_time)
@_time = now
totalTime: ->
@_time - @_start
droppedFrames: ->
_.filter @_frames, (t) -> t > (1 / 60) * 1.1
droppedFrameRate: ->
Utils.round(@droppedFrames().length / @totalTime(), 1)
averageFPS: ->
Utils.round(@_frames.length / Utils.sum(@_frames), 1)
testLayers = (n, options={}, callback) ->
options = _.defaults options,
width: 500
height: 500
time: 1
Framer.CurrentContext.reset()
counter = 0
endGame = ->
counter++
if counter == n
fps.stop()
callback?(fps)
root = new Layer
width: options.width
height: options.height
backgroundColor: "rgba(0, 0, 0, .1)"
root.center()
layers = for i in [0..n]
layer = new Layer
x: Math.random() * options.width - (.5 * 100)
y: Math.random() * options.height - (.5 * 100)
backgroundColor: Color.random(.3)
superLayer: root
fps = new FPS
for layer in layers
animation = layer.animate
properties:
x: Math.random() * options.width
y: Math.random() * options.height
time: options.time
animation.on(Events.AnimationEnd, endGame)
start = 40
current = start
minFPS = 40
stats = []
next = ->
testLayers current, {}, (fps) ->
print "#{current} layers at #{fps.averageFPS()} fps"
stats.push([current, fps.averageFPS()])
current = current + start
if fps.averageFPS() > minFPS
next()
else
Framer.CurrentContext.reset()
drawChart(stats)
next()
drawChart = (stats) ->
canvasLayer = new Layer
width: 500
height: 300
backgroundColor: "white"
canvasLayer.center()
canvasLayer.html = """<canvas
width='#{canvasLayer.width - 20}px'
height='#{canvasLayer.height-20}px'>
</canvas>"""
canvasElement = canvasLayer.querySelectorAll("canvas")[0]
data =
labels: stats.map (i) -> i[0].toString()
datasets: [
{
fillColor: "rgba(220,220,220,0.2)"
strokeColor: "rgba(220,220,220,1)"
pointColor: "rgba(220,220,220,1)"
pointStrokeColor: "#fff"
pointHighlightFill: "#fff"
pointHighlightStroke: "rgba(220,220,220,1)"
data: stats.map (i) -> i[1]
}
]
options = {}
lineChart = new Chart(canvasElement.getContext("2d")).Line(data, options);

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit cfb7d76

Please sign in to comment.