Skip to content
Permalink
Browse files

Add some stats to performance in Safari

  • Loading branch information
koenbok committed Sep 26, 2014
1 parent 9a04efe commit bd01fd823d4f017b7aece8a535de197fdb0ac640
Showing with 60 additions and 8 deletions.
  1. +7 −3 Makefile
  2. +17 −0 framer/Utils.coffee
  3. +16 −1 perf/init.coffee
  4. +20 −4 perf/init.js
@@ -60,11 +60,15 @@ safariw:
perf:
$(browserify) perf/init.coffee -o perf/init.js
$(bin)/phantomjs perf/runner.js perf/index.html
perf%watch:

perf%watch:
perfw:
$(watch) make perf

perf-safari:
$(browserify) perf/init.coffee -o perf/init.js
open -g -a Safari perf/index.html
perf-safariw:
$(watch) make perf-safari


# Building and uploading the site

@@ -49,6 +49,23 @@ Utils.arrayPrev = (arr, item) ->
arr[arr.indexOf(item) - 1] or _.last arr


######################################################
# MATH

Utils.sum = (arr) -> _.reduce arr, (a, b) -> a + b
Utils.average = (arr) -> Utils.sum(arr) / arr.length
Utils.mean = Utils.average
Utils.median = (x) ->
return null if x.length is 0

sorted = x.slice().sort (a, b) ->
a - b

if sorted.length % 2 is 1
sorted[(sorted.length - 1) / 2]
else
(sorted[(sorted.length / 2) - 1] + sorted[sorted.length / 2]) / 2

######################################################
# ANIMATION

@@ -79,6 +79,8 @@ Utils.domComplete ->
c = 0
allResults = []
minFPS = 50
tooSlow = 0
tooSlowMax = 2
@@ -87,6 +89,8 @@ Utils.domComplete ->
if results
allResults.push(results)
output = "#{c} - #{results.layers}"
output += "\tBuild: #{Utils.round(results.buildTotal, 0)}ms /#{Utils.round(results.buildLayer, 2)}ms"
output += "\tFPS: #{Utils.round(results.fps.fps, 1)}"
@@ -96,10 +100,21 @@ Utils.domComplete ->
if results.fps.fps < minFPS
tooSlow++

if c < 100 and tooSlow < tooSlowMax
# if c < 100 and tooSlow < tooSlowMax
if c < 30 and tooSlow < tooSlowMax
c++
run {n: c * 20}, callback
else

buildTotal = Utils.round(Utils.average(_.map(allResults, (i) -> i.buildLayer)), 3) * 1000
layerTotal = Utils.round(Utils.average(_.map(allResults, (i) -> i.fps.fps / i.layers)), 3) * 1000

print "#{buildTotal} (build)"
print "#{layerTotal} (layer)"

print "BUILD LOOKS SLOW > 440" if buildTotal > 440
print "LAYER LOOKS SLOW > 760" if layerTotal > 760

window.phantomComplete = true

callback()

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

0 comments on commit bd01fd8

Please sign in to comment.