Commit c570d719 authored by Denys Mishunov's avatar Denys Mishunov

Re-factored user timing metrics

After implementing the metrics for WebIDE, the patters have
changed a bit. This commit sets the snippet's measurements on
par with those of WebIDE.
parent 3934a31b
<script> <script>
import { debounce } from 'lodash'; import { debounce } from 'lodash';
import { initEditorLite } from '~/blob/utils'; import { initEditorLite } from '~/blob/utils';
import { import { SNIPPET_MEASURE_BLOBS_CONTENT } from '~/performance_constants';
SNIPPET_MARK_BLOBS_CONTENT,
SNIPPET_MARK_EDIT_APP_START, import eventHub from './eventhub';
SNIPPET_MEASURE_BLOBS_CONTENT,
SNIPPET_MEASURE_BLOBS_CONTENT_WITHIN_APP,
} from '~/performance_constants';
export default { export default {
props: { props: {
...@@ -48,12 +45,8 @@ export default { ...@@ -48,12 +45,8 @@ export default {
this.editor.onDidChangeModelContent(debounce(this.onFileChange.bind(this), 250)); this.editor.onDidChangeModelContent(debounce(this.onFileChange.bind(this), 250));
window.requestAnimationFrame(() => { this.$nextTick(() => {
if (!performance.getEntriesByName(SNIPPET_MARK_BLOBS_CONTENT).length) { eventHub.$emit(SNIPPET_MEASURE_BLOBS_CONTENT);
performance.mark(SNIPPET_MARK_BLOBS_CONTENT);
performance.measure(SNIPPET_MEASURE_BLOBS_CONTENT);
performance.measure(SNIPPET_MEASURE_BLOBS_CONTENT_WITHIN_APP, SNIPPET_MARK_EDIT_APP_START);
}
}); });
}, },
beforeDestroy() { beforeDestroy() {
......
import createEventHub from '~/helpers/event_hub_factory';
export default createEventHub();
...@@ -25,11 +25,8 @@ import ErrorMessage from './error_message.vue'; ...@@ -25,11 +25,8 @@ import ErrorMessage from './error_message.vue';
import CommitEditorHeader from './commit_sidebar/editor_header.vue'; import CommitEditorHeader from './commit_sidebar/editor_header.vue';
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin'; import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
const markPerformance = params => {
performanceMarkAndMeasure(params);
};
const markTreePerformance = () => { const markTreePerformance = () => {
markPerformance({ performanceMarkAndMeasure({
mark: WEBIDE_MARK_TREE_FINISH, mark: WEBIDE_MARK_TREE_FINISH,
measures: [ measures: [
{ {
...@@ -41,7 +38,7 @@ const markTreePerformance = () => { ...@@ -41,7 +38,7 @@ const markTreePerformance = () => {
}); });
}; };
const markEditorLoadPerformance = () => { const markEditorLoadPerformance = () => {
markPerformance({ performanceMarkAndMeasure({
mark: WEBIDE_MARK_FILE_FINISH, mark: WEBIDE_MARK_FILE_FINISH,
measures: [ measures: [
{ {
...@@ -53,7 +50,7 @@ const markEditorLoadPerformance = () => { ...@@ -53,7 +50,7 @@ const markEditorLoadPerformance = () => {
}); });
}; };
const markEditorInteractionPerformance = () => { const markEditorInteractionPerformance = () => {
markPerformance({ performanceMarkAndMeasure({
mark: WEBIDE_MARK_FILE_FINISH, mark: WEBIDE_MARK_FILE_FINISH,
measures: [ measures: [
{ {
...@@ -115,7 +112,7 @@ export default { ...@@ -115,7 +112,7 @@ export default {
document.querySelector('.navbar-gitlab').classList.add(`theme-${this.themeName}`); document.querySelector('.navbar-gitlab').classList.add(`theme-${this.themeName}`);
}, },
beforeCreate() { beforeCreate() {
performance.mark(WEBIDE_MARK_APP_START); performanceMarkAndMeasure({ mark: WEBIDE_MARK_APP_START });
}, },
methods: { methods: {
...mapActions(['toggleFileFinder']), ...mapActions(['toggleFileFinder']),
......
...@@ -12,7 +12,6 @@ export const SNIPPET_MARK_BLOBS_CONTENT = 'snippet-blobs-content-finished'; ...@@ -12,7 +12,6 @@ export const SNIPPET_MARK_BLOBS_CONTENT = 'snippet-blobs-content-finished';
// Measures // Measures
export const SNIPPET_MEASURE_BLOBS_CONTENT = 'snippet-blobs-content'; export const SNIPPET_MEASURE_BLOBS_CONTENT = 'snippet-blobs-content';
export const SNIPPET_MEASURE_BLOBS_CONTENT_WITHIN_APP = 'snippet-blobs-content-within-app';
// //
// WebIDE namespace // WebIDE namespace
......
...@@ -6,7 +6,12 @@ import { __, sprintf } from '~/locale'; ...@@ -6,7 +6,12 @@ import { __, sprintf } from '~/locale';
import TitleField from '~/vue_shared/components/form/title.vue'; import TitleField from '~/vue_shared/components/form/title.vue';
import { redirectTo, joinPaths } from '~/lib/utils/url_utility'; import { redirectTo, joinPaths } from '~/lib/utils/url_utility';
import FormFooterActions from '~/vue_shared/components/form/form_footer_actions.vue'; import FormFooterActions from '~/vue_shared/components/form/form_footer_actions.vue';
import { SNIPPET_MARK_EDIT_APP_START } from '~/performance_constants'; import {
SNIPPET_MARK_EDIT_APP_START,
SNIPPET_MEASURE_BLOBS_CONTENT,
} from '~/performance_constants';
import eventHub from '~/blob/components/eventhub';
import { performanceMarkAndMeasure } from '~/performance_utils';
import UpdateSnippetMutation from '../mutations/updateSnippet.mutation.graphql'; import UpdateSnippetMutation from '../mutations/updateSnippet.mutation.graphql';
import CreateSnippetMutation from '../mutations/createSnippet.mutation.graphql'; import CreateSnippetMutation from '../mutations/createSnippet.mutation.graphql';
...@@ -17,11 +22,14 @@ import { ...@@ -17,11 +22,14 @@ import {
SNIPPET_VISIBILITY_PRIVATE, SNIPPET_VISIBILITY_PRIVATE,
} from '../constants'; } from '../constants';
import defaultVisibilityQuery from '../queries/snippet_visibility.query.graphql'; import defaultVisibilityQuery from '../queries/snippet_visibility.query.graphql';
import { markBlobPerformance } from '../utils/blob';
import SnippetBlobActionsEdit from './snippet_blob_actions_edit.vue'; import SnippetBlobActionsEdit from './snippet_blob_actions_edit.vue';
import SnippetVisibilityEdit from './snippet_visibility_edit.vue'; import SnippetVisibilityEdit from './snippet_visibility_edit.vue';
import SnippetDescriptionEdit from './snippet_description_edit.vue'; import SnippetDescriptionEdit from './snippet_description_edit.vue';
eventHub.$on(SNIPPET_MEASURE_BLOBS_CONTENT, markBlobPerformance);
export default { export default {
components: { components: {
SnippetDescriptionEdit, SnippetDescriptionEdit,
...@@ -119,7 +127,7 @@ export default { ...@@ -119,7 +127,7 @@ export default {
}, },
}, },
beforeCreate() { beforeCreate() {
performance.mark(SNIPPET_MARK_EDIT_APP_START); performanceMarkAndMeasure({ mark: SNIPPET_MARK_EDIT_APP_START });
}, },
created() { created() {
window.addEventListener('beforeunload', this.onBeforeUnload); window.addEventListener('beforeunload', this.onBeforeUnload);
......
...@@ -5,11 +5,18 @@ import SnippetHeader from './snippet_header.vue'; ...@@ -5,11 +5,18 @@ import SnippetHeader from './snippet_header.vue';
import SnippetTitle from './snippet_title.vue'; import SnippetTitle from './snippet_title.vue';
import SnippetBlob from './snippet_blob_view.vue'; import SnippetBlob from './snippet_blob_view.vue';
import CloneDropdownButton from '~/vue_shared/components/clone_dropdown.vue'; import CloneDropdownButton from '~/vue_shared/components/clone_dropdown.vue';
import { SNIPPET_VISIBILITY_PUBLIC } from '~/snippets/constants';
import {
SNIPPET_MARK_VIEW_APP_START,
SNIPPET_MEASURE_BLOBS_CONTENT,
} from '~/performance_constants';
import { performanceMarkAndMeasure } from '~/performance_utils';
import eventHub from '~/blob/components/eventhub';
import { getSnippetMixin } from '../mixins/snippets'; import { getSnippetMixin } from '../mixins/snippets';
import { SNIPPET_VISIBILITY_PUBLIC } from '~/snippets/constants'; import { markBlobPerformance } from '../utils/blob';
import { SNIPPET_MARK_VIEW_APP_START } from '~/performance_constants'; eventHub.$on(SNIPPET_MEASURE_BLOBS_CONTENT, markBlobPerformance);
export default { export default {
components: { components: {
...@@ -30,7 +37,7 @@ export default { ...@@ -30,7 +37,7 @@ export default {
}, },
}, },
beforeCreate() { beforeCreate() {
performance.mark(SNIPPET_MARK_VIEW_APP_START); performanceMarkAndMeasure({ mark: SNIPPET_MARK_VIEW_APP_START });
}, },
}; };
</script> </script>
......
...@@ -7,6 +7,8 @@ import { ...@@ -7,6 +7,8 @@ import {
SNIPPET_LEVELS_MAP, SNIPPET_LEVELS_MAP,
SNIPPET_VISIBILITY, SNIPPET_VISIBILITY,
} from '../constants'; } from '../constants';
import { performanceMarkAndMeasure } from '~/performance_utils';
import { SNIPPET_MARK_BLOBS_CONTENT, SNIPPET_MEASURE_BLOBS_CONTENT } from '~/performance_constants';
const createLocalId = () => uniqueId('blob_local_'); const createLocalId = () => uniqueId('blob_local_');
...@@ -79,3 +81,16 @@ export const defaultSnippetVisibilityLevels = arr => { ...@@ -79,3 +81,16 @@ export const defaultSnippetVisibilityLevels = arr => {
} }
return []; return [];
}; };
export const markBlobPerformance = () => {
performanceMarkAndMeasure({
mark: SNIPPET_MARK_BLOBS_CONTENT,
measures: [
{
name: SNIPPET_MEASURE_BLOBS_CONTENT,
start: undefined,
end: SNIPPET_MARK_BLOBS_CONTENT,
},
],
});
};
import { import { SNIPPET_MEASURE_BLOBS_CONTENT } from '~/performance_constants';
SNIPPET_MARK_VIEW_APP_START, import eventHub from '~/blob/components/eventhub';
SNIPPET_MARK_BLOBS_CONTENT,
SNIPPET_MEASURE_BLOBS_CONTENT,
SNIPPET_MEASURE_BLOBS_CONTENT_WITHIN_APP,
} from '~/performance_constants';
export default { export default {
props: { props: {
...@@ -17,12 +13,8 @@ export default { ...@@ -17,12 +13,8 @@ export default {
}, },
}, },
mounted() { mounted() {
window.requestAnimationFrame(() => { this.$nextTick(() => {
if (!performance.getEntriesByName(SNIPPET_MARK_BLOBS_CONTENT).length) { eventHub.$emit(SNIPPET_MEASURE_BLOBS_CONTENT);
performance.mark(SNIPPET_MARK_BLOBS_CONTENT);
performance.measure(SNIPPET_MEASURE_BLOBS_CONTENT);
performance.measure(SNIPPET_MEASURE_BLOBS_CONTENT_WITHIN_APP, SNIPPET_MARK_VIEW_APP_START);
}
}); });
}, },
}; };
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment