     drawEpoch._frameSecond = @_frameSecond
 
     Foundation.resetGlobalCounts()
-    startTime = currentSecond()
-
-    @_resetThisCyclesStats()
+    # startTime = currentSecond()
+
+    ArtFrameStats.startFrame()
+
+    # @_resetThisCyclesStats()
     @processingCycle = true
     @_processCycleExceptDraw()
 

    # I think it's OK to just push the event-epoch out (which should allow the request-image-dialog to fire)
    # eventEpoch.flushEpochNow  = => @flushEpochNow()

    eventEpoch.logEvent = (name, id) => @logEvent name, id

  allowFluxOnIdle: (nextNSeconds)->
    @_fluxOnIdleOkUntil = currentSecond() + nextNSeconds

  _resetThisCyclesStats: ->
    @performanceSamples = {}

  ############################
  # FrameStats: DEPRICATED - use ArtFrameStats
  ############################

  logEvent: (name, id) ->
    @globalEpochStats?.logEvent name, id

  addPerformanceSample: (name, value) ->
    throw new Error "@performanceSamples not set" unless @performanceSamples
    @performanceSamples[name] = (@performanceSamples[name] || 0) + value
    # @fluxFrameTime = @reactFrameTime = @eventFrameTime = @idleFrametime = @aimUpdateFrameTime = @drawFrameTime = 0

  timerStack = []
  timePerformance: (name, f) ->
    start = @startTimePerformance()
    f()
    @endTimePerformance name, start

  startTimePerformance: ->
    start = currentSecond()
    timerStack.push 0
    start

  endTimePerformance: (name, start) ->
    subTimeTotal = timerStack.pop()
    elapsedTime = currentSecond() - start
    if (tsl = timerStack.length) > 0
      timerStack[tsl-1] += elapsedTime

    @addPerformanceSample name, elapsedTime - subTimeTotal

  ############################
  # </FrameStats>

StateEpoch = require './StateEpoch'
DrawEpoch = require './Drawing/DrawEpoch'
IdleEpoch = require './IdleEpoch'

ArtFrameStats = require 'art-frame-stats'

{
  log, requestAnimationFrame, miniInspect, time, arrayWithout, currentSecond, Epoch
