Upgrade to ExtJS 4.0.7 - Released 10/19/2011
[extjs.git] / examples / desktop / SystemStatus.js
index f1fe398..193adeb 100644 (file)
@@ -1,3 +1,17 @@
+/*
+
+This file is part of Ext JS 4
+
+Copyright (c) 2011 Sencha Inc
+
+Contact:  http://www.sencha.com/contact
+
+GNU General Public License Usage
+This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file.  Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
+
+If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
+
+*/
 /*!
 * Ext JS Library 4.0
 * Copyright(c) 2006-2011 Sencha Inc.
@@ -14,6 +28,8 @@ Ext.define('MyDesktop.SystemStatus', {
 
     id: 'systemstatus',
 
+    refreshRate: 500,
+
     init : function() {
         // No launcher means we don't appear on the Start Menu...
 //        this.launcher = {
@@ -409,6 +425,7 @@ Ext.define('MyDesktop.SystemStatus', {
         var me = this;
         clearTimeout(me.updateTimer);
         me.updateTimer = setTimeout(function() {
+            var start = new Date().getTime();
             if (me.pass % 3 === 0) {
                 me.memoryStore.loadData(me.generateData(me.memoryArray));
             }
@@ -418,8 +435,15 @@ Ext.define('MyDesktop.SystemStatus', {
             }
 
             me.generateCpuLoad();
+
+            var end = new Date().getTime();
+
+            // no more than 25% average CPU load
+            me.refreshRate = Math.max(me.refreshRate, (end - start) * 4);
+
             me.updateCharts();
             me.pass++;
-        }, 500);
+        }, me.refreshRate);
     }
 });
+