[client-sync] metrics(Part 5) Rename PerformanceMonitor to GlobalTimer

Summary:
This global module wasn't really related to performance, but rather with
timing things across different processes in the app. I believe this name
is more appropriate.

Test Plan: I can still use NylasEnv.timer (instead of NylasEnv.perf)

Reviewers: spang, evan

Reviewed By: spang, evan

Differential Revision: https://phab.nylas.com/D3972
This commit is contained in:
Juan Tejada 2017-02-17 16:12:20 -08:00
parent 8afb14c4c6
commit 39c6c04bc4
6 changed files with 12 additions and 10 deletions

View file

@ -48,7 +48,7 @@ class ComposerWithWindowProps extends React.Component {
_onDraftReady = () => {
this.refs.composer.focus().then(() => {
const timeInMs = NylasEnv.perf.stop("Popout Draft");
const timeInMs = NylasEnv.timer.stop("Popout Draft");
if (!NylasEnv.inDevMode() && !NylasEnv.inSpecMode()) {
if (timeInMs && timeInMs <= 4000) {
Actions.recordUserEvent("Composer Popout Timed", {timeInMs})

View file

@ -22,7 +22,10 @@ export class ArchiveButton extends React.Component {
}
_onArchive = (event) => {
const tasks = TaskFactory.tasksForArchiving({threads: this.props.items, source: "Toolbar Button: Thread List"})
const tasks = TaskFactory.tasksForArchiving({
threads: this.props.items,
source: "Toolbar Button: Thread List",
})
Actions.queueTasks(tasks);
Actions.popSheet();
event.stopPropagation();

View file

@ -8,6 +8,7 @@ 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';
@ -15,7 +16,6 @@ import ConfigMigrator from './config-migrator';
import ApplicationMenu from './application-menu';
import AutoUpdateManager from './auto-update-manager';
import SystemTrayManager from './system-tray-manager';
import PerformanceMonitor from './performance-monitor'
import DefaultClientHelper from '../default-client-helper';
import NylasProtocolHandler from './nylas-protocol-handler';
import PackageMigrationManager from './package-migration-manager';
@ -73,7 +73,7 @@ export default class Application extends EventEmitter {
});
this.systemTrayManager = new SystemTrayManager(process.platform, this);
this._databasePhase = 'setup';
this.perf = new PerformanceMonitor()
this.timer = new GlobalTimer()
this.setupJavaScriptArguments();
this.handleEvents();

View file

@ -5,7 +5,7 @@ const BUFFER_SIZE = 100;
* A benchmarking system to keep track of start and end times for various
* event types.
*/
export default class PerformanceMonitor {
export default class GlobalTimer {
constructor() {
this._doneRuns = {}
this._pendingRuns = {}
@ -70,5 +70,4 @@ export default class PerformanceMonitor {
clear(key) {
delete this._doneRuns[key]
}
}

View file

@ -275,7 +275,7 @@ class DraftStore extends NylasStore {
_onPopoutBlankDraft = () => {
Actions.recordUserEvent("Draft Created", {type: "new"});
NylasEnv.perf.start("Popout Draft");
NylasEnv.timer.start("Popout Draft");
return DraftFactory.createDraft().then((draft) => {
return this._finalizeAndPersistNewMessage(draft).then(({draftClientId}) => {
return this._onPopoutDraftClientId(draftClientId, {newDraft: true});
@ -287,7 +287,7 @@ class DraftStore extends NylasStore {
if (draftClientId == null) {
throw new Error("DraftStore::onPopoutDraftId - You must provide a draftClientId");
}
NylasEnv.perf.start("Popout Draft");
NylasEnv.timer.start("Popout Draft");
const title = options.newDraft ? "New Message" : "Message";
return this.sessionForClientId(draftClientId).then((session) => {

View file

@ -195,7 +195,7 @@ class NylasEnvConstructor
@packages.onDidActivateInitialPackages => @watchThemes()
@windowEventHandler = new WindowEventHandler()
@perf = remote.getGlobal('application').perf
@timer = remote.getGlobal('application').timer
@localSyncEmitter = new Emitter
@ -739,7 +739,7 @@ class NylasEnvConstructor
# plugins needs to be loaded.
populateHotWindow: (event, loadSettings) =>
if /composer/.test(loadSettings.windowType)
NylasEnv.perf.split("Popout Draft")
NylasEnv.timer.split("Popout Draft")
@loadSettings = loadSettings
@constructor.loadSettings = loadSettings