Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Bug 1129041 - Remove User Timing shim.
Browse files Browse the repository at this point in the history
  • Loading branch information
eliperelman authored and rvandermeulen committed Mar 19, 2015
1 parent ccd701f commit 9043c11
Show file tree
Hide file tree
Showing 35 changed files with 2 additions and 385 deletions.
1 change: 0 additions & 1 deletion apps/camera/index.html
Expand Up @@ -22,7 +22,6 @@

<!-- <script defer src="/shared/js/l10n.js"></script> -->
<!-- <script defer src="/shared/js/async_storage.js"></script> -->
<!-- <script defer src="/shared/js/usertiming.js"></script> -->
<!-- <script defer src="/shared/js/performance_testing_helper.js"></script> -->
<!-- <script defer src="/shared/js/media/jpeg_metadata_parser.js"></script> -->
<!-- <script defer src="/shared/js/media/get_video_rotation.js"></script> -->
Expand Down
1 change: 0 additions & 1 deletion apps/camera/js/app.js
Expand Up @@ -2,7 +2,6 @@ define(function(require, exports, module) {
'use strict';

// For perf-measurement related utilities
require('usertiming');
require('performance-testing-helper');

/**
Expand Down
3 changes: 1 addition & 2 deletions apps/camera/js/config/require.js
Expand Up @@ -25,8 +25,7 @@ requirejs.config({
'evt': '../bower_components/evt/index',
'drag': '../bower_components/drag/index',
'device-orientation': '../bower_components/device-orientation/index',
'stop-recording-event': '../shared/js/stop_recording_event',
'usertiming': '../shared/js/usertiming'
'stop-recording-event': '../shared/js/stop_recording_event'
},

// If your package uses relative `require()` paths
Expand Down
1 change: 0 additions & 1 deletion apps/clock/index.html
Expand Up @@ -31,7 +31,6 @@
The following scripts are lazy loaded but left here to ensure
they get copied over from shared during the build
-->
<!-- <script defer src="/shared/js/usertiming.js"></script> -->
<!-- <script defer src="/shared/js/performance_testing_helper.js"></script> -->
<!-- <script defer src="/shared/js/l10n.js"></script> -->
<!-- <script defer src="/shared/js/l10n_date.js"></script> -->
Expand Down
1 change: 0 additions & 1 deletion apps/clock/js/app.js
@@ -1,7 +1,6 @@
define(function(require) {
'use strict';

require('shared/js/usertiming');
require('shared/js/performance_testing_helper');

var Tabs = require('tabs');
Expand Down
1 change: 0 additions & 1 deletion apps/communications/contacts/index.html
Expand Up @@ -56,7 +56,6 @@
<script defer src="/shared/js/l10n_date.js"></script>
<script defer src="/contacts/js/activities.js"></script>
<script defer src="/shared/js/lazy_loader.js"></script>
<script defer src="/shared/js/usertiming.js"></script>
<script defer src="/shared/js/contact_photo_helper.js"></script>

<script defer src="/shared/js/async_storage.js"></script>
Expand Down
1 change: 0 additions & 1 deletion apps/communications/contacts/test/unit/contacts_test.js
Expand Up @@ -8,7 +8,6 @@
MockImportStatusData, MockMozContacts
*/

require('/shared/js/usertiming.js');
requireApp('communications/contacts/test/unit/mock_l10n.js');
requireApp('communications/contacts/test/unit/mock_contacts_list_obj.js');
requireApp('communications/contacts/test/unit/mock_cookie.js');
Expand Down
1 change: 0 additions & 1 deletion apps/communications/contacts/test/unit/views/list_test.js
Expand Up @@ -19,7 +19,6 @@
/* global LazyLoader */

require('/shared/js/lazy_loader.js');
require('/shared/js/usertiming.js');
require('/shared/js/text_normalizer.js');
require('/shared/js/tag_visibility_monitor.js');
require('/shared/js/contacts/utilities/dom.js');
Expand Down
1 change: 0 additions & 1 deletion apps/communications/dialer/index.html
Expand Up @@ -41,7 +41,6 @@
<script defer src="/shared/js/lazy_loader.js"></script>
<script defer src="/shared/js/font_size_utils.js"></script>
<script defer src="/shared/js/lazy_l10n.js"></script>
<script defer src="/shared/js/usertiming.js"></script>
<script defer src="/dialer/js/index.js"></script>

<script defer src="/shared/js/dialer/utils.js"></script>
Expand Down
1 change: 0 additions & 1 deletion apps/communications/dialer/test/unit/call_log_test.js
Expand Up @@ -6,7 +6,6 @@
CallGroupMenu, Utils, MockMozContacts */

require('/shared/js/dialer/utils.js');
require('/shared/js/usertiming.js');

require('/shared/test/unit/mocks/dialer/mock_contacts.js');
require('/shared/test/unit/mocks/dialer/mock_lazy_l10n.js');
Expand Down
1 change: 0 additions & 1 deletion apps/communications/dialer/test/unit/index_test.js
Expand Up @@ -5,7 +5,6 @@
require('/shared/test/unit/mocks/dialer/mock_keypad.js');
require('/shared/test/unit/mocks/mock_lazy_loader.js');
require('/shared/test/unit/mocks/mock_lazy_l10n.js');
require('/shared/js/usertiming.js');
require('/dialer/test/unit/mock_call_handler.js');
require('/dialer/test/unit/mock_navbar_manager.js');

Expand Down
1 change: 0 additions & 1 deletion apps/costcontrol/fte.html
Expand Up @@ -43,7 +43,6 @@
<script type="text/javascript" src="shared/js/async_storage.js"></script>
<script type="text/javascript" src="shared/js/settings_listener.js"></script>
<script type="text/javascript" src="shared/js/lazy_loader.js"></script>
<script type="text/javascript" defer src="shared/js/usertiming.js"></script>
<script type="text/javascript" defer src="shared/js/performance_testing_helper.js"></script>

<!-- Gaia Components -->
Expand Down
1 change: 0 additions & 1 deletion apps/costcontrol/index.html
Expand Up @@ -58,7 +58,6 @@
<script type="text/javascript" defer src="shared/js/settings_listener.js"></script>
<script type="text/javascript" defer src="shared/js/lazy_loader.js"></script>
<script type="text/javascript" defer src="shared/js/format.js"></script>
<script type="text/javascript" defer src="/shared/js/usertiming.js"></script>
<script type="text/javascript" defer src="/shared/js/performance_testing_helper.js"></script>
<script type="text/javascript" defer src="/shared/js/url_helper.js"></script>

Expand Down
1 change: 0 additions & 1 deletion apps/costcontrol/settings.html
Expand Up @@ -39,7 +39,6 @@
<!-- TODO: Lazyly loaded, remove when mozHour12 is part of the platform
<script type="text/javascript" defer src="shared/js/date_time_helper.js"></script>
-->
<script defer src="/shared/js/usertiming.js"></script>
<script defer src="/shared/js/performance_testing_helper.js"></script>

<!-- Gaia Components -->
Expand Down
1 change: 0 additions & 1 deletion apps/costcontrol/test/unit/startup_test.js
Expand Up @@ -6,7 +6,6 @@
/* exported PerformanceTestingHelper */
'use strict';

require('/shared/js/usertiming.js');
require('/shared/test/unit/mocks/mock_lazy_loader.js');
require('/test/unit/mock_debug.js');
require('/test/unit/mock_common.js');
Expand Down
162 changes: 0 additions & 162 deletions apps/email/js/html_cache_restore.js
Expand Up @@ -34,168 +34,6 @@ var HTML_COOKIE_CACHE_MAX_SEGMENTS = 40;
// true to the first call made to it.
window.htmlCacheRestorePendingMessage = [];

// START COPY usertiming.js
// A copy instead of a separate script because the gaia build system is not
// set up to inline this with our main script element, and we want this work
// to be done after the cache restore, but want to trigger the events that
// may be met by the cache right away without waiting for another script
// load after html_cache_restore.
(function() {
// This is a PARTIAL implementation of User Timing, specifically only the
// methods `performance.mark` and `performance.measure`, as those are required
// for performance testing. The rest of the API will come once this API is
// properly implemented in Gecko and this shim of these methods can be removed
var performance = window.performance;
var console = window.console;

if (typeof performance.mark === 'function') {
return;
}

// Create a performance entry in the logs in a certain format so performance
// tests can extract and parse
var logEntry = function(entry) {
setTimeout(function() {
var message = 'Performance Entry: ' +
entry.entryType + '|' +
entry.name + '|' +
entry.startTime + '|' +
entry.duration + '|' +
(entry.time || 0);

console.log(message);
}, 0);
};

// only used for measure(), to quickly see the latest timestamp of a mark
var marks = {};

/**
* UserTiming mark
* http://www.w3.org/TR/user-timing/#dom-performance-mark
*
* @param {string} markName Mark name
*/
performance.mark = function(markName) {
var now = performance.now();
var epoch = Date.now();

// mark name is required
if (typeof markName === 'undefined') {
throw new SyntaxError('Mark name must be specified');
}

// mark name can't be a NT timestamp
if (performance.timing && markName in performance.timing) {
throw new SyntaxError('Mark name is not allowed');
}

if (!marks[markName]) {
marks[markName] = [];
}

marks[markName].push(now);

// add to perf timeline as well
logEntry({
entryType: 'mark',
name: markName,
startTime: now,
duration: 0,
time: epoch // NON-STANDARD EXTENSION
});
};

/**
* UserTiming measure
* http://www.w3.org/TR/user-timing/#dom-performance-measure
*
* @param {string} measureName Measure name
* @param {string} [startMark] Start mark name
* @param {string} [endMark] End mark name
*/
performance.measure = function(measureName, startMark, endMark) {
var now = performance.now();
var epoch = Date.now();

if (!measureName) {
throw new Error('Measure must be specified');
}

// if there isn't a startMark, we measure from navigationStart to now
if (!startMark) {
logEntry({
entryType: 'measure',
name: measureName,
startTime: 0,
duration: now,
time: epoch // NON-STANDARD EXTENSION
});

return;
}

// If there is a startMark, check for it first in the NavigationTiming
// interface, then check our own marks.
var startMarkTime = 0;
if (performance.timing && startMark in performance.timing) {
// mark cannot have a timing of 0
if (startMark !== 'navigationStart' &&
performance.timing[startMark] === 0) {
throw new Error(startMark + ' has a timing of 0');
}

// time is the offset of this mark to navigationStart's time
startMarkTime = performance.timing[startMark] -
performance.timing.navigationStart;
} else {
if (startMark in marks) {
startMarkTime = marks[startMark][marks[startMark].length - 1];
} else {
throw new Error(startMark + ' mark not found');
}
}

// If there is a endMark, check for it first in the NavigationTiming
// interface, then check our own marks.
var endMarkTime = now;

if (endMark) {
endMarkTime = 0;

if (performance.timing && endMark in performance.timing) {
// mark cannot have a timing of 0
if (endMark !== 'navigationStart' &&
performance.timing[endMark] === 0) {
throw new Error(endMark + ' has a timing of 0');
}

// time is the offset of this mark to navigationStart's time
endMarkTime = performance.timing[endMark] -
performance.timing.navigationStart;
} else {
if (endMark in marks) {
endMarkTime = marks[endMark][marks[endMark].length - 1];
} else {
throw new Error(endMark + ' mark not found');
}
}
}

// add to our measure array
var duration = endMarkTime - startMarkTime;

logEntry({
entryType: 'measure',
name: measureName,
startTime: startMarkTime,
duration: duration,
time: epoch // NON-STANDARD EXTENSION
});
};
}());
// END COPY performance_testing_helper.js

(function() {
var selfNode = document.querySelector('[data-loadsrc]'),
loader = selfNode.dataset.loader,
Expand Down
1 change: 0 additions & 1 deletion apps/fm/index.html
Expand Up @@ -14,7 +14,6 @@
<script defer src="shared/js/airplane_mode_helper.js"></script>

<!-- For perf-measurement related utilities -->
<script defer src="shared/js/usertiming.js"></script>
<script defer src="shared/js/performance_testing_helper.js"></script>

<script defer src="js/fm.js"></script>
Expand Down
1 change: 0 additions & 1 deletion apps/fm/test/unit/fm_test.js
@@ -1,4 +1,3 @@
require('/shared/js/usertiming.js');
requireApp('shared/js/airplane_mode_helper.js');
requireApp('fm/js/fm.js');
require('/shared/test/unit/load_body_html_helper.js');
Expand Down
1 change: 0 additions & 1 deletion apps/gallery/index.html
Expand Up @@ -22,7 +22,6 @@
<link rel="localization" href="/shared/locales/date/date.{locale}.properties">
<link rel="localization" href="/shared/locales/media/media.{locale}.properties">
<!-- Shared code -->
<script defer src="shared/js/usertiming.js"></script>
<script defer src="shared/js/performance_testing_helper.js"></script>
<script defer src="shared/js/l10n.js"></script>
<script defer src="shared/js/l10n_date.js"></script>
Expand Down
1 change: 0 additions & 1 deletion apps/music/index.html
Expand Up @@ -20,7 +20,6 @@
<link rel="localization" href="locales/music.{locale}.properties">
<link rel="localization" href="/shared/locales/media/media.{locale}.properties">
<!-- Shared code -->
<script defer src="shared/js/usertiming.js"></script>
<script defer src="shared/js/performance_testing_helper.js"></script>
<script defer src="shared/js/l10n.js"></script>
<script defer src="shared/js/device_storage/enumerate_all.js"></script>
Expand Down
1 change: 0 additions & 1 deletion apps/settings/index.html
Expand Up @@ -76,7 +76,6 @@
<script src="/shared/js/lazy_loader.js"></script>

<!-- For perf-measurement related utilities -->
<script src="/shared/js/usertiming.js"></script>
<script defer="" src="/shared/js/performance_testing_helper.js"></script>

<!-- Screen layout watcher -->
Expand Down
1 change: 0 additions & 1 deletion apps/settings/test/unit/app_starter_test.js
Expand Up @@ -12,7 +12,6 @@ Object.defineProperty(document, 'readyState', {
value: 'loading',
configurable: true
});
require('/shared/js/usertiming.js');
require('/js/startup.js');

suite('AppStarter', function() {
Expand Down
3 changes: 1 addition & 2 deletions apps/settings/test/unit/setup.js
Expand Up @@ -16,8 +16,7 @@ requireApp('settings/js/vendor/alameda.js', (function() {
},
shim: {
'settings': {
exports: 'Settings',
deps: ['shared/usertiming']
exports: 'Settings'
},
'shared/lazy_loader': {
exports: 'LazyLoader'
Expand Down
1 change: 0 additions & 1 deletion apps/sms/index.html
Expand Up @@ -57,7 +57,6 @@
<!-- Should be removed while gecko support navigator.mozHour12 API -->
<script defer src="shared/js/date_time_helper.js"></script>
<script defer src="shared/js/template.js"></script>
<script defer src="shared/js/usertiming.js"></script>
<script defer src="shared/js/performance_testing_helper.js"></script>
<script defer src="shared/js/async_storage.js"></script>
<script defer src="shared/js/lazy_loader.js"></script>
Expand Down
1 change: 0 additions & 1 deletion apps/sms/test/unit/sms_test.js
Expand Up @@ -11,7 +11,6 @@
require('/shared/js/lazy_loader.js');
require('/shared/js/gesture_detector.js');
require('/shared/js/sticky_header.js');
require('/shared/js/usertiming.js');
require('/shared/js/performance_testing_helper.js');
require('/shared/test/unit/mocks/mock_gesture_detector.js');
require('/shared/test/unit/mocks/mock_l10n.js');
Expand Down
1 change: 0 additions & 1 deletion apps/sms/test/unit/startup_test.js
Expand Up @@ -8,7 +8,6 @@
'use strict';

require('/js/event_dispatcher.js');
require('/shared/js/usertiming.js');

require('/test/unit/mock_message_manager.js');
require('/test/unit/mock_navigation.js');
Expand Down
1 change: 0 additions & 1 deletion apps/sms/test/unit/thread_list_ui_test.js
Expand Up @@ -10,7 +10,6 @@

'use strict';

require('/shared/js/usertiming.js');
requireApp('sms/js/utils.js');
requireApp('sms/js/recipients.js');
requireApp('sms/js/drafts.js');
Expand Down
1 change: 0 additions & 1 deletion apps/system/index.html
Expand Up @@ -10,7 +10,6 @@
<link rel="stylesheet" type="text/css" href="style/system/initlogo.css">

<!-- Shared code -->
<script src="shared/js/usertiming.js"></script>
<script src="shared/js/l10n.js"></script>
<script src="shared/js/l10n_date.js"></script>
<script src="shared/js/idletimer.js"></script>
Expand Down
1 change: 0 additions & 1 deletion apps/system/test/unit/bootstrap_test.js
Expand Up @@ -5,7 +5,6 @@
MockTrustedUIManager */

requireApp('system/shared/js/performance_testing_helper.js');
requireApp('system/shared/js/usertiming.js');
requireApp('system/shared/js/async_storage.js');
requireApp('system/shared/js/lazy_loader.js');
requireApp('system/shared/js/screen_layout.js');
Expand Down

0 comments on commit 9043c11

Please sign in to comment.