Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
with
966 additions
and 0 deletions.
- +3 −0 Makefile
- +36 −0 extras/Perf.framer/.gitignore
- +138 −0 extras/Perf.framer/app.coffee
- +2 −0 extras/Perf.framer/app.js
- 0 extras/{Studio.framer → Perf.framer}/framer/coffee-script.js
- 0 extras/{Studio.framer → Perf.framer}/framer/config.json
- 0 extras/{Studio.framer/framer/framer.js → Perf.framer/framer/framer.debug.js}
- 0 extras/{Studio.framer → Perf.framer}/framer/framer.debug.js.map
- +762 −0 extras/Perf.framer/framer/framer.generated.js
- 0 extras/{Studio.framer → Perf.framer}/framer/framer.init.js
- +1 −0 extras/Perf.framer/framer/framer.js
- 0 extras/{Studio.framer → Perf.framer}/framer/framer.js.map
- +12 −0 extras/Perf.framer/framer/framer.modules.js
- BIN extras/Perf.framer/framer/images/background.png
- BIN extras/Perf.framer/framer/images/cursor-active.png
- BIN extras/Perf.framer/framer/images/cursor-active@2x.png
- BIN extras/{Studio.framer → Perf.framer}/framer/images/cursor.png
- BIN extras/{Studio.framer → Perf.framer}/framer/images/cursor@2x.png
- BIN extras/Perf.framer/framer/images/icon-120.png
- BIN extras/Perf.framer/framer/images/icon-152.png
- BIN extras/Perf.framer/framer/images/icon-76.png
- BIN extras/Perf.framer/framer/images/icon-arrow.png
- BIN extras/Perf.framer/framer/images/icon-arrow@2x.png
- BIN extras/Perf.framer/framer/images/icon-close.png
- BIN extras/Perf.framer/framer/images/icon-close@2x.png
- BIN extras/Perf.framer/framer/images/icon-framer.png
- BIN extras/Perf.framer/framer/images/icon-framer@2x.png
- BIN extras/Perf.framer/framer/images/icon-share.png
- BIN extras/Perf.framer/framer/images/icon-share@2x.png
- 0 extras/{Studio.framer → Perf.framer}/framer/mirror.css
- 0 extras/{Studio.framer → Perf.framer}/framer/style.css
- 0 extras/{Studio.framer → Perf.framer}/framer/version
- 0 extras/Perf.framer/images/.gitkeep
- +2 −0 extras/{Studio.framer → Perf.framer}/index.html
- +10 −0 extras/Perf.framer/modules/myModule.coffee
@@ -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); | ||
|
||
|
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.