Commit 206f145c authored by Mark Florian's avatar Mark Florian

Merge branch 'dmishunov-snippet-user-timing' into 'master'

Re-factored user timing metrics

See merge request gitlab-org/gitlab!44021
parents 4209bebf 7ebf08ef
<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,13 +45,7 @@ export default { ...@@ -48,13 +45,7 @@ export default {
this.editor.onDidChangeModelContent(debounce(this.onFileChange.bind(this), 250)); this.editor.onDidChangeModelContent(debounce(this.onFileChange.bind(this), 250));
window.requestAnimationFrame(() => { eventHub.$emit(SNIPPET_MEASURE_BLOBS_CONTENT);
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);
}
});
}, },
beforeDestroy() { beforeDestroy() {
this.editor.dispose(); this.editor.dispose();
......
import createEventHub from '~/helpers/event_hub_factory';
export default createEventHub();
...@@ -25,49 +25,21 @@ import ErrorMessage from './error_message.vue'; ...@@ -25,49 +25,21 @@ 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 => { import { measurePerformance } from '../utils';
performanceMarkAndMeasure(params);
};
const markTreePerformance = () => {
markPerformance({
mark: WEBIDE_MARK_TREE_FINISH,
measures: [
{
name: WEBIDE_MEASURE_TREE_FROM_REQUEST,
start: undefined,
end: WEBIDE_MARK_TREE_FINISH,
},
],
});
};
const markEditorLoadPerformance = () => {
markPerformance({
mark: WEBIDE_MARK_FILE_FINISH,
measures: [
{
name: WEBIDE_MEASURE_FILE_FROM_REQUEST,
start: undefined,
end: WEBIDE_MARK_FILE_FINISH,
},
],
});
};
const markEditorInteractionPerformance = () => {
markPerformance({
mark: WEBIDE_MARK_FILE_FINISH,
measures: [
{
name: WEBIDE_MEASURE_FILE_AFTER_INTERACTION,
start: WEBIDE_MARK_FILE_CLICKED,
end: WEBIDE_MARK_FILE_FINISH,
},
],
});
};
eventHub.$on(WEBIDE_MEASURE_TREE_FROM_REQUEST, markTreePerformance); eventHub.$on(WEBIDE_MEASURE_TREE_FROM_REQUEST, () =>
eventHub.$on(WEBIDE_MEASURE_FILE_FROM_REQUEST, markEditorLoadPerformance); measurePerformance(WEBIDE_MARK_TREE_FINISH, WEBIDE_MEASURE_TREE_FROM_REQUEST),
eventHub.$on(WEBIDE_MEASURE_FILE_AFTER_INTERACTION, markEditorInteractionPerformance); );
eventHub.$on(WEBIDE_MEASURE_FILE_FROM_REQUEST, () =>
measurePerformance(WEBIDE_MARK_FILE_FINISH, WEBIDE_MEASURE_FILE_FROM_REQUEST),
);
eventHub.$on(WEBIDE_MEASURE_FILE_AFTER_INTERACTION, () =>
measurePerformance(
WEBIDE_MARK_FILE_FINISH,
WEBIDE_MEASURE_FILE_AFTER_INTERACTION,
WEBIDE_MARK_FILE_CLICKED,
),
);
export default { export default {
components: { components: {
...@@ -115,7 +87,7 @@ export default { ...@@ -115,7 +87,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']),
......
...@@ -37,9 +37,7 @@ export default { ...@@ -37,9 +37,7 @@ export default {
}, },
updated() { updated() {
if (this.currentTree?.tree?.length) { if (this.currentTree?.tree?.length) {
this.$nextTick(() => { eventHub.$emit(WEBIDE_MEASURE_TREE_FROM_REQUEST);
eventHub.$emit(WEBIDE_MEASURE_TREE_FROM_REQUEST);
});
} }
}, },
methods: { methods: {
......
...@@ -300,13 +300,11 @@ export default { ...@@ -300,13 +300,11 @@ export default {
}); });
this.$emit('editorSetup'); this.$emit('editorSetup');
this.$nextTick(() => { if (performance.getEntriesByName(WEBIDE_MARK_FILE_CLICKED).length) {
if (performance.getEntriesByName(WEBIDE_MARK_FILE_CLICKED).length) { eventHub.$emit(WEBIDE_MEASURE_FILE_AFTER_INTERACTION);
eventHub.$emit(WEBIDE_MEASURE_FILE_AFTER_INTERACTION); } else {
} else { eventHub.$emit(WEBIDE_MEASURE_FILE_FROM_REQUEST);
eventHub.$emit(WEBIDE_MEASURE_FILE_FROM_REQUEST); }
}
});
}, },
refreshEditorDimensions() { refreshEditorDimensions() {
if (this.showEditor) { if (this.showEditor) {
......
import { languages } from 'monaco-editor'; import { languages } from 'monaco-editor';
import { flatten, isString } from 'lodash'; import { flatten, isString } from 'lodash';
import { SIDE_LEFT, SIDE_RIGHT } from './constants'; import { SIDE_LEFT, SIDE_RIGHT } from './constants';
import { performanceMarkAndMeasure } from '~/performance_utils';
const toLowerCase = x => x.toLowerCase(); const toLowerCase = x => x.toLowerCase();
...@@ -137,3 +138,21 @@ export function readFileAsDataURL(file) { ...@@ -137,3 +138,21 @@ export function readFileAsDataURL(file) {
export function getFileEOL(content = '') { export function getFileEOL(content = '') {
return content.includes('\r\n') ? 'CRLF' : 'LF'; return content.includes('\r\n') ? 'CRLF' : 'LF';
} }
export const measurePerformance = (
mark,
measureName,
measureStart = undefined,
measureEnd = mark,
) => {
performanceMarkAndMeasure({
mark,
measures: [
{
name: measureName,
start: measureStart,
end: measureEnd,
},
],
});
};
...@@ -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
......
...@@ -4,9 +4,7 @@ export const performanceMarkAndMeasure = ({ mark, measures = [] } = {}) => { ...@@ -4,9 +4,7 @@ export const performanceMarkAndMeasure = ({ mark, measures = [] } = {}) => {
performance.mark(mark); performance.mark(mark);
} }
measures.forEach(measure => { measures.forEach(measure => {
window.requestAnimationFrame(() => performance.measure(measure.name, measure.start, measure.end);
performance.measure(measure.name, measure.start, measure.end),
);
}); });
}); });
}; };
...@@ -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,6 @@ export default { ...@@ -17,12 +13,6 @@ export default {
}, },
}, },
mounted() { mounted() {
window.requestAnimationFrame(() => { eventHub.$emit(SNIPPET_MEASURE_BLOBS_CONTENT);
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);
}
});
}, },
}; };
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