diff --git a/src/app.js b/src/app.js index 59c47b38aa..7b99ce4cb9 100644 --- a/src/app.js +++ b/src/app.js @@ -816,6 +816,16 @@ var run = function () { config.set('autoCompile', autoCompile) }) + var warnMsg = ' Last compilation took {X}ms. We suggest to turn off autocompilation.' + compiler.event.register('compilationSpeed', (speed) => { + $('#warnCompilationSlow').html('') + $('#header #menu .settingsView').css('color', '') + if (speed > 1000) { + $('#warnCompilationSlow').html(warnMsg.replace('{X}', speed)) + $('#header #menu .settingsView').css('color', '#FF8B8B') + } + }) + function runCompiler () { if (transactionDebugger.isActive) return diff --git a/src/app/compiler.js b/src/app/compiler.js index f8e6ff6223..fe155e6547 100644 --- a/src/app/compiler.js +++ b/src/app/compiler.js @@ -9,7 +9,7 @@ var utils = require('./utils') var EventManager = require('ethereum-remix').lib.EventManager /* - trigger compilationFinished, compilerLoaded, compilationStarted + trigger compilationFinished, compilerLoaded, compilationStarted, compilationSpeed */ function Compiler (handleImportCall) { var self = this @@ -28,6 +28,18 @@ function Compiler (handleImportCall) { optimize = _optimize } + var compilationStartTime = null + this.event.register('compilationFinished', (success, data, source) => { + if (success && compilationStartTime) { + this.event.trigger('compilationSpeed', [(new Date().getTime()) - compilationStartTime]) + } + compilationStartTime = null + }) + + this.event.register('compilationStarted', () => { + compilationStartTime = new Date().getTime() + }) + var internalCompile = function (files, target, missingInputs) { gatherImports(files, target, missingInputs, function (error, input) { if (error) { diff --git a/src/app/settings-tab.js b/src/app/settings-tab.js index 1a5f076c27..02acd37e40 100644 --- a/src/app/settings-tab.js +++ b/src/app/settings-tab.js @@ -34,6 +34,9 @@ var css = csjs` .checkboxText { margin-left: 3px; } + #warnCompilationSlow { + color: #FF8B8B; + } } ` module.exports = settingsTab @@ -58,7 +61,7 @@ function settingsTab () {
- Auto Compile + Auto Compile