From a9a57de215b54cc9e0cf37e2d28dd12caa5048c7 Mon Sep 17 00:00:00 2001 From: Ben Gotow Date: Fri, 23 Jun 2017 16:30:28 -0700 Subject: [PATCH] Remove more perf and timing stuff --- .../internal_packages/composer/lib/main.jsx | 13 ---- .../lib/items/account-error-notif.jsx | 4 - .../client-app/src/browser/application.es6 | 1 - .../client-app/src/browser/global-timer.es6 | 73 ------------------- packages/client-app/src/flux/actions.es6 | 3 - .../src/flux/stores/draft-store.es6 | 3 - .../src/flux/stores/file-download-store.es6 | 16 ---- .../src/flux/tasks/send-draft-task.es6 | 28 ------- packages/client-app/src/nylas-env.es6 | 5 -- 9 files changed, 146 deletions(-) delete mode 100644 packages/client-app/src/browser/global-timer.es6 diff --git a/packages/client-app/internal_packages/composer/lib/main.jsx b/packages/client-app/internal_packages/composer/lib/main.jsx index b625846ef..5865fd7c6 100644 --- a/packages/client-app/internal_packages/composer/lib/main.jsx +++ b/packages/client-app/internal_packages/composer/lib/main.jsx @@ -48,19 +48,6 @@ class ComposerWithWindowProps extends React.Component { _onDraftReady = () => { this.refs.composer.focus().then(() => { - if (NylasEnv.timer.isPending('open-composer-window')) { - const actionTimeMs = NylasEnv.timer.stop('open-composer-window'); - if (actionTimeMs && actionTimeMs <= 4000) { - Actions.recordUserEvent("Composer Popout Timed", {timeInMs: actionTimeMs}) - } - // TODO time when plugins actually get loaded in - Actions.recordPerfMetric({ - action: 'open-composer-window', - actionTimeMs, - maxValue: 4000, - sample: 0.9, - }) - } NylasEnv.displayWindow(); if (this.state.errorMessage) { diff --git a/packages/client-app/internal_packages/notifications/lib/items/account-error-notif.jsx b/packages/client-app/internal_packages/notifications/lib/items/account-error-notif.jsx index 0182cc30c..32be377e5 100644 --- a/packages/client-app/internal_packages/notifications/lib/items/account-error-notif.jsx +++ b/packages/client-app/internal_packages/notifications/lib/items/account-error-notif.jsx @@ -51,10 +51,6 @@ export default class AccountErrorNotification extends React.Component { } _onCheckAgain(event, account) { - if (event.metaKey) { - Actions.debugSync() - return - } clearTimeout(this._checkingTimeout) this.setState({checking: true}) this._checkingTimeout = setTimeout(() => this.setState({checking: false}), 10000) diff --git a/packages/client-app/src/browser/application.es6 b/packages/client-app/src/browser/application.es6 index 2b41c71b1..27ec69e74 100644 --- a/packages/client-app/src/browser/application.es6 +++ b/packages/client-app/src/browser/application.es6 @@ -9,7 +9,6 @@ import path from 'path'; import proc from 'child_process' import {EventEmitter} from 'events'; -import GlobalTimer from './global-timer' import WindowManager from './window-manager'; import FileListCache from './file-list-cache'; import DatabaseReader from './database-reader'; diff --git a/packages/client-app/src/browser/global-timer.es6 b/packages/client-app/src/browser/global-timer.es6 deleted file mode 100644 index 5375bcc82..000000000 --- a/packages/client-app/src/browser/global-timer.es6 +++ /dev/null @@ -1,73 +0,0 @@ -import Utils from '../../src/flux/models/utils' -const BUFFER_SIZE = 100; - -/** - * A benchmarking system to keep track of start and end times for various - * event types. - */ -export default class GlobalTimer { - constructor() { - this._doneRuns = {} - this._pendingRuns = {} - } - - start(key) { - if (!this._pendingRuns[key]) { - this._pendingRuns[key] = [Date.now()] - } - } - - /** - * This will add split points in an ongoing run (or do nothing if no run - * has started). Useful for fine-grained debugging of long timers. - */ - split(key) { - if (!this._pendingRuns[key]) { return {} } - this._pendingRuns[key].push(Date.now()) - return { - split: this.calcSplit(this._pendingRuns[key]), - total: this.calcTotal(this._pendingRuns[key]), - } - } - - stop(key) { - if (!this._pendingRuns[key]) { return 0 } - if (!this._doneRuns[key]) { this._doneRuns[key] = [] } - this._pendingRuns[key].push(Date.now()); - const total = this.calcTotal(this._pendingRuns[key]) - this._doneRuns[key].push(this._pendingRuns[key]) - if (this._doneRuns[key].length > BUFFER_SIZE) { - this._doneRuns[key].shift() - } - delete this._pendingRuns[key] - return total - } - - calcSplit(curRun) { - return curRun[curRun.length - 1] - curRun[curRun.length - 2] - } - - calcTotal(curRun) { - return curRun[curRun.length - 1] - curRun[0] - } - - calcMean(key) { - return Utils.mean(this.totals(key)) - } - - calcStdev(key) { - return Utils.stdev(this.totals(key)) - } - - totals(key) { - return this._doneRuns[key].map(this.calcTotal) - } - - runsFor(key) { - return this._doneRuns[key] - } - - clear(key) { - delete this._doneRuns[key] - } -} diff --git a/packages/client-app/src/flux/actions.es6 b/packages/client-app/src/flux/actions.es6 index c849080ee..164866bd9 100644 --- a/packages/client-app/src/flux/actions.es6 +++ b/packages/client-app/src/flux/actions.es6 @@ -511,7 +511,6 @@ class Actions { Public: Publish a user event to any analytics services linked to N1. */ static recordUserEvent = ActionScopeWorkWindow; - static recordPerfMetric = ActionScopeWorkWindow; static addMailRule = ActionScopeWindow; static reorderMailRule = ActionScopeWindow; @@ -554,8 +553,6 @@ class Actions { static expandInitialSyncState = ActionScopeWindow; static resetEmailCache = ActionScopeGlobal; - - static debugSync = ActionScopeGlobal; } diff --git a/packages/client-app/src/flux/stores/draft-store.es6 b/packages/client-app/src/flux/stores/draft-store.es6 index 5623e0447..0deb0d458 100644 --- a/packages/client-app/src/flux/stores/draft-store.es6 +++ b/packages/client-app/src/flux/stores/draft-store.es6 @@ -275,7 +275,6 @@ class DraftStore extends NylasStore { _onPopoutBlankDraft = () => { Actions.recordUserEvent("Draft Created", {type: "new"}); - NylasEnv.timer.start('open-composer-window'); return DraftFactory.createDraft().then((draft) => { return this._finalizeAndPersistNewMessage(draft).then(({draftClientId}) => { return this._onPopoutDraftClientId(draftClientId, {newDraft: true}); @@ -287,8 +286,6 @@ class DraftStore extends NylasStore { if (draftClientId == null) { throw new Error("DraftStore::onPopoutDraftId - You must provide a draftClientId"); } - NylasEnv.timer.start('open-composer-window'); - const title = options.newDraft ? "New Message" : "Message"; return this.sessionForClientId(draftClientId).then((session) => { return session.changes.commit().then(() => { diff --git a/packages/client-app/src/flux/stores/file-download-store.es6 b/packages/client-app/src/flux/stores/file-download-store.es6 index 6231d13d7..900fc60d0 100644 --- a/packages/client-app/src/flux/stores/file-download-store.es6 +++ b/packages/client-app/src/flux/stores/file-download-store.es6 @@ -101,16 +101,7 @@ export class Download { let startRequest = null; - const before = Date.now(); - const onFailed = (err) => { - Actions.recordPerfMetric({ - action: 'file-download', - accountId: this.accountId, - actionTimeMs: Date.now() - before, - maxValue: 10 * 60 * 1000, - succeeded: false, - }) this.request = null; stream.end(); if (!this.retryWithBackoff || this.attempts >= this.maxAttempts) { @@ -127,13 +118,6 @@ export class Download { }; const onSuccess = () => { - Actions.recordPerfMetric({ - action: 'file-download', - accountId: this.accountId, - actionTimeMs: Date.now() - before, - maxValue: 10 * 60 * 1000, - succeeded: true, - }) this.request = null; stream.end(); this.state = State.Finished; diff --git a/packages/client-app/src/flux/tasks/send-draft-task.es6 b/packages/client-app/src/flux/tasks/send-draft-task.es6 index eb52d1fc2..26b74302f 100644 --- a/packages/client-app/src/flux/tasks/send-draft-task.es6 +++ b/packages/client-app/src/flux/tasks/send-draft-task.es6 @@ -199,38 +199,10 @@ export default class SendDraftTask extends BaseDraftTask { if (this.playSound && NylasEnv.config.get("core.sending.sounds")) { SoundRegistry.playSound('send'); } -<<<<<<< HEAD - if (NylasEnv.timer.isPending(this._timerKey)) { - const account = AccountStore.accountForId(this.draft.accountId) - const provider = account ? account.provider : 'Unknown provider' - Actions.recordPerfMetric({ - provider, - action: 'send-draft', - actionTimeMs: NylasEnv.timer.stop(this._timerKey), - maxValue: 60 * 1000, - succeeded: true, - }) - } -======= ->>>>>>> parent of ae9aede30... [client-app] Measure and report sending times return Promise.resolve(Task.Status.Success); } onError = (err) => { -<<<<<<< HEAD - if (NylasEnv.timer.isPending(this._timerKey)) { - const account = AccountStore.accountForId(this.draft.accountId) - const provider = account ? account.provider : 'Unknown provider' - Actions.recordPerfMetric({ - provider, - action: 'send-draft', - actionTimeMs: NylasEnv.timer.stop(this._timerKey), - maxValue: 60 * 1000, - succeeded: false, - }) - } -======= ->>>>>>> parent of ae9aede30... [client-app] Measure and report sending times if (err instanceof BaseDraftTask.DraftNotFoundError) { return Promise.resolve(Task.Status.Continue); } diff --git a/packages/client-app/src/nylas-env.es6 b/packages/client-app/src/nylas-env.es6 index 89586af21..e877ee720 100644 --- a/packages/client-app/src/nylas-env.es6 +++ b/packages/client-app/src/nylas-env.es6 @@ -225,8 +225,6 @@ export default class NylasEnvConstructor { this.packages.onDidActivateInitialPackages(() => this.watchThemes()); this.windowEventHandler = new WindowEventHandler(); - this.timer = remote.getGlobal('application').timer; - this.globalWindowEmitter = new Emitter(); if (!this.inSpecMode()) { @@ -933,9 +931,6 @@ export default class NylasEnvConstructor { // This also means that the windowType has changed and a different set of // plugins needs to be loaded. populateHotWindow(event, loadSettings) { - if (/composer/.test(loadSettings.windowType)) { - NylasEnv.timer.split("Popout Draft"); - } this.loadSettings = loadSettings; this.constructor.loadSettings = loadSettings;