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>
import { debounce } from 'lodash';
import { initEditorLite } from '~/blob/utils';
import {
SNIPPET_MARK_BLOBS_CONTENT,
SNIPPET_MARK_EDIT_APP_START,
SNIPPET_MEASURE_BLOBS_CONTENT,
SNIPPET_MEASURE_BLOBS_CONTENT_WITHIN_APP,
} from '~/performance_constants';
import { SNIPPET_MEASURE_BLOBS_CONTENT } from '~/performance_constants';
import eventHub from './eventhub';
export default {
props: {
......@@ -48,12 +45,8 @@ export default {
this.editor.onDidChangeModelContent(debounce(this.onFileChange.bind(this), 250));
window.requestAnimationFrame(() => {
if (!performance.getEntriesByName(SNIPPET_MARK_BLOBS_CONTENT).length) {
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);
}
this.$nextTick(() => {
eventHub.$emit(SNIPPET_MEASURE_BLOBS_CONTENT);
});
},
beforeDestroy() {
......
import createEventHub from '~/helpers/event_hub_factory';
export default createEventHub();
......@@ -25,11 +25,8 @@ import ErrorMessage from './error_message.vue';
import CommitEditorHeader from './commit_sidebar/editor_header.vue';
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
const markPerformance = params => {
performanceMarkAndMeasure(params);
};
const markTreePerformance = () => {
markPerformance({
performanceMarkAndMeasure({
mark: WEBIDE_MARK_TREE_FINISH,
measures: [
{
......@@ -41,7 +38,7 @@ const markTreePerformance = () => {
});
};
const markEditorLoadPerformance = () => {
markPerformance({
performanceMarkAndMeasure({
mark: WEBIDE_MARK_FILE_FINISH,
measures: [
{
......@@ -53,7 +50,7 @@ const markEditorLoadPerformance = () => {
});
};
const markEditorInteractionPerformance = () => {
markPerformance({
performanceMarkAndMeasure({
mark: WEBIDE_MARK_FILE_FINISH,
measures: [
{
......@@ -115,7 +112,7 @@ export default {
document.querySelector('.navbar-gitlab').classList.add(`theme-${this.themeName}`);
},
beforeCreate() {
performance.mark(WEBIDE_MARK_APP_START);
performanceMarkAndMeasure({ mark: WEBIDE_MARK_APP_START });
},
methods: {
...mapActions(['toggleFileFinder']),
......
......@@ -12,7 +12,6 @@ export const SNIPPET_MARK_BLOBS_CONTENT = 'snippet-blobs-content-finished';
// Measures
export const SNIPPET_MEASURE_BLOBS_CONTENT = 'snippet-blobs-content';
export const SNIPPET_MEASURE_BLOBS_CONTENT_WITHIN_APP = 'snippet-blobs-content-within-app';
//
// WebIDE namespace
......
......@@ -6,7 +6,12 @@ import { __, sprintf } from '~/locale';
import TitleField from '~/vue_shared/components/form/title.vue';
import { redirectTo, joinPaths } from '~/lib/utils/url_utility';
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 CreateSnippetMutation from '../mutations/createSnippet.mutation.graphql';
......@@ -17,11 +22,14 @@ import {
SNIPPET_VISIBILITY_PRIVATE,
} from '../constants';
import defaultVisibilityQuery from '../queries/snippet_visibility.query.graphql';
import { markBlobPerformance } from '../utils/blob';
import SnippetBlobActionsEdit from './snippet_blob_actions_edit.vue';
import SnippetVisibilityEdit from './snippet_visibility_edit.vue';
import SnippetDescriptionEdit from './snippet_description_edit.vue';
eventHub.$on(SNIPPET_MEASURE_BLOBS_CONTENT, markBlobPerformance);
export default {
components: {
SnippetDescriptionEdit,
......@@ -119,7 +127,7 @@ export default {
},
},
beforeCreate() {
performance.mark(SNIPPET_MARK_EDIT_APP_START);
performanceMarkAndMeasure({ mark: SNIPPET_MARK_EDIT_APP_START });
},
created() {
window.addEventListener('beforeunload', this.onBeforeUnload);
......
......@@ -5,11 +5,18 @@ import SnippetHeader from './snippet_header.vue';
import SnippetTitle from './snippet_title.vue';
import SnippetBlob from './snippet_blob_view.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 { 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 {
components: {
......@@ -30,7 +37,7 @@ export default {
},
},
beforeCreate() {
performance.mark(SNIPPET_MARK_VIEW_APP_START);
performanceMarkAndMeasure({ mark: SNIPPET_MARK_VIEW_APP_START });
},
};
</script>
......
......@@ -7,6 +7,8 @@ import {
SNIPPET_LEVELS_MAP,
SNIPPET_VISIBILITY,
} from '../constants';
import { performanceMarkAndMeasure } from '~/performance_utils';
import { SNIPPET_MARK_BLOBS_CONTENT, SNIPPET_MEASURE_BLOBS_CONTENT } from '~/performance_constants';
const createLocalId = () => uniqueId('blob_local_');
......@@ -79,3 +81,16 @@ export const defaultSnippetVisibilityLevels = arr => {
}
return [];
};
export const markBlobPerformance = () => {
performanceMarkAndMeasure({
mark: SNIPPET_MARK_BLOBS_CONTENT,
measures: [
{
name: SNIPPET_MEASURE_BLOBS_CONTENT,
start: undefined,
end: SNIPPET_MARK_BLOBS_CONTENT,
},
],
});
};
import {
SNIPPET_MARK_VIEW_APP_START,
SNIPPET_MARK_BLOBS_CONTENT,
SNIPPET_MEASURE_BLOBS_CONTENT,
SNIPPET_MEASURE_BLOBS_CONTENT_WITHIN_APP,
} from '~/performance_constants';
import { SNIPPET_MEASURE_BLOBS_CONTENT } from '~/performance_constants';
import eventHub from '~/blob/components/eventhub';
export default {
props: {
......@@ -17,12 +13,8 @@ export default {
},
},
mounted() {
window.requestAnimationFrame(() => {
if (!performance.getEntriesByName(SNIPPET_MARK_BLOBS_CONTENT).length) {
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);
}
this.$nextTick(() => {
eventHub.$emit(SNIPPET_MEASURE_BLOBS_CONTENT);
});
},
};
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