         @errorCount += stat.errorCount
         return this
 
+class StatProvider
+    constructor: () ->
+        @stats = {}
+
+    _getStat : (key)->
+        if not @stats[key]?
+            @stats[key] = new Stat()
+        return @stats[key]
+
+    add: (key, num)->
+        @_getStat(key).add(num)
+
+    addError : (key)->
+        @_getStat(key).addError()
+
+        
+    
+
+
 
 # eventCount contains the event to create browser
 class Client extends EventEmitter
     constructor : (options) ->
         # id is a unique client identifier in all client processes
         {@eventDescriptors, @createBrowser, 
-        @appAddress, @cbhost,
+        @appAddress, @cbhost, @stats,
         @id, @serverLogging} = options
         @eventContext = new benchmarkConfig.EventContext({clientId:@id})
         @eventQueue = new benchmarkConfig.EventQueue({
             descriptors : @eventDescriptors
             context : @eventContext
             })
-        @stat= new Stat()
-        @otherStat = {}
 
     addChild : (child) ->
         @once('browserconfig', (browserConfig)->

            if not @browserConfig.appId? or not @browserConfig.browserId?
                @_fatalErrorHandler(new Error("Something is wrong, no browserid detected."))

            @otherStat.initialConnectTime = @_timpeElapsed()
            @_createSocket()
            @_initialSocketIo()

    _initialSocketIo : ()->
        @_initStartTs()
        @socket.on('connect', ()=>
            @otherStat.connectTime = @_timpeElapsed()
            @socket.emit('auth', @browserConfig.appId, @browserConfig.appInstanceId,
                @browserConfig.browserId)
            @_initStartTs()

            )
        )
        @socket.once 'PageLoaded', (nodes, registeredEventTypes, clientComponents, compressionTable) =>
            @stats.add('pageLoaded', @_timpeElapsed())
            @compressionTable = if compressionTable? then compressionTable else {}
            for k, v of @compressionTable
                do (k, v)=>
