| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234 | 
							- <!DOCTYPE html>
 
- <html>
 
- <head>
 
-   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 
-   <title>The source code</title>
 
-   <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
 
-   <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
 
-   <style type="text/css">
 
-     .highlight { display: block; background-color: #ddd; }
 
-   </style>
 
-   <script type="text/javascript">
 
-     function highlight() {
 
-       document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
 
-     }
 
-   </script>
 
- </head>
 
- <body onload="prettyPrint(); highlight();">
 
-   <pre class="prettyprint lang-js"><span id='Ext-perf-Monitor'>/**
 
- </span> * @class Ext.perf.Monitor
 
-  * @singleton
 
-  * @private
 
-  */
 
- Ext.define('Ext.perf.Monitor', {
 
-     singleton: true,
 
-     alternateClassName: 'Ext.Perf',
 
-     requires: [
 
-         'Ext.perf.Accumulator'
 
-     ],
 
-     constructor: function () {
 
-         this.accumulators = [];
 
-         this.accumulatorsByName = {};
 
-     },
 
-     calibrate: function () {
 
-         var accum = new Ext.perf.Accumulator('$'),
 
-             total = accum.total,
 
-             getTimestamp = Ext.perf.Accumulator.getTimestamp,
 
-             count = 0,
 
-             frame,
 
-             endTime,
 
-             startTime;
 
-         startTime = getTimestamp();
 
-         do {
 
-             frame = accum.enter();
 
-             frame.leave();
 
-             ++count;
 
-         } while (total.sum < 100);
 
-         endTime = getTimestamp();
 
-         return (endTime - startTime) / count;
 
-     },
 
-     get: function (name) {
 
-         var me = this,
 
-             accum = me.accumulatorsByName[name];
 
-         if (!accum) {
 
-             me.accumulatorsByName[name] = accum = new Ext.perf.Accumulator(name);
 
-             me.accumulators.push(accum);
 
-         }
 
-         return accum;
 
-     },
 
-     enter: function (name) {
 
-         return this.get(name).enter();
 
-     },
 
-     monitor: function (name, fn, scope) {
 
-         this.get(name).monitor(fn, scope);
 
-     },
 
-     report: function () {
 
-         var me = this,
 
-             accumulators = me.accumulators,
 
-             calibration = me.calibrate();
 
-         accumulators.sort(function (a, b) {
 
-             return (a.name < b.name) ? -1 : ((b.name < a.name) ? 1 : 0);
 
-         });
 
-         me.updateGC();
 
-         Ext.log('Calibration: ' + Math.round(calibration * 100) / 100 + ' msec/sample');
 
-         Ext.each(accumulators, function (accum) {
 
-             Ext.log(accum.format(calibration));
 
-         });
 
-     },
 
-     getData: function (all) {
 
-         var ret = {},
 
-             accumulators = this.accumulators;
 
-         Ext.each(accumulators, function (accum) {
 
-             if (all || accum.count) {
 
-                 ret[accum.name] = accum.getData();
 
-             }
 
-         });
 
-         return ret;
 
-     },
 
-     reset: function(){
 
-         Ext.each(this.accumulators, function(accum){
 
-             var me = accum;
 
-             me.count = me.childCount = me.depth = me.maxDepth = 0;
 
-             me.pure = {
 
-                 min: Number.MAX_VALUE,
 
-                 max: 0,
 
-                 sum: 0
 
-             };
 
-             me.total = {
 
-                 min: Number.MAX_VALUE,
 
-                 max: 0,
 
-                 sum: 0
 
-             };
 
-         });
 
-     },
 
-     updateGC: function () {
 
-         var accumGC = this.accumulatorsByName.GC,
 
-             toolbox = Ext.senchaToolbox,
 
-             bucket;
 
-         if (accumGC) {
 
-             accumGC.count = toolbox.garbageCollectionCounter || 0;
 
-             if (accumGC.count) {
 
-                 bucket = accumGC.pure;
 
-                 accumGC.total.sum = bucket.sum = toolbox.garbageCollectionMilliseconds;
 
-                 bucket.min = bucket.max = bucket.sum / accumGC.count;
 
-                 bucket = accumGC.total;
 
-                 bucket.min = bucket.max = bucket.sum / accumGC.count;
 
-             }
 
-         }
 
-     },
 
-     watchGC: function () {
 
-         Ext.perf.getTimestamp(); // initializes SenchaToolbox (if available)
 
-         var toolbox = Ext.senchaToolbox;
 
-         if (toolbox) {
 
-             this.get("GC");
 
-             toolbox.watchGarbageCollector(false); // no logging, just totals
 
-         }
 
-     },
 
-     setup: function (config) {
 
-         if (!config) {
 
-             config = {
 
-                 /*insertHtml: {
 
-                     'Ext.dom.Helper': 'insertHtml'
 
-                 },*/
 
-                 /*xtplCompile: {
 
-                     'Ext.XTemplateCompiler': 'compile'
 
-                 },*/
 
- //                doInsert: {
 
- //                    'Ext.Template': 'doInsert'
 
- //                },
 
- //                applyOut: {
 
- //                    'Ext.XTemplate': 'applyOut'
 
- //                },
 
-                 render: {
 
-                     'Ext.AbstractComponent': 'render'
 
-                 },
 
- //                fnishRender: {
 
- //                    'Ext.AbstractComponent': 'finishRender'
 
- //                },
 
- //                renderSelectors: {
 
- //                    'Ext.AbstractComponent': 'applyRenderSelectors'
 
- //                },
 
- //                compAddCls: {
 
- //                    'Ext.AbstractComponent': 'addCls'
 
- //                },
 
- //                compRemoveCls: {
 
- //                    'Ext.AbstractComponent': 'removeCls'
 
- //                },
 
- //                getStyle: {
 
- //                    'Ext.core.Element': 'getStyle'
 
- //                },
 
- //                setStyle: {
 
- //                    'Ext.core.Element': 'setStyle'
 
- //                },
 
- //                addCls: {
 
- //                    'Ext.core.Element': 'addCls'
 
- //                },
 
- //                removeCls: {
 
- //                    'Ext.core.Element': 'removeCls'
 
- //                },
 
- //                measure: {
 
- //                    'Ext.layout.component.Component': 'measureAutoDimensions'
 
- //                },
 
- //                moveItem: {
 
- //                    'Ext.layout.Layout': 'moveItem'
 
- //                },
 
- //                layoutFlush: {
 
- //                    'Ext.layout.Context': 'flush'
 
- //                },
 
-                 layout: {
 
-                     'Ext.layout.Context': 'run'
 
-                 }
 
-             };
 
-         }
 
-         this.currentConfig = config;
 
-         var key, prop,
 
-             accum, className, methods;
 
-         for (key in config) {
 
-             if (config.hasOwnProperty(key)) {
 
-                 prop = config[key];
 
-                 accum = Ext.Perf.get(key);
 
-                 for (className in prop) {
 
-                     if (prop.hasOwnProperty(className)) {
 
-                         methods = prop[className];
 
-                         accum.tap(className, methods);
 
-                     }
 
-                 }
 
-             }
 
-         }
 
-         this.watchGC();
 
-     }
 
- });
 
- </pre>
 
- </body>
 
- </html>
 
 
  |