Skip to content

Commit

Permalink
resource: remove slow element ratio (ser) (#30972)
Browse files Browse the repository at this point in the history
  • Loading branch information
samouri committed Nov 3, 2020
1 parent 0b44c4e commit 3c1d10a
Show file tree
Hide file tree
Showing 7 changed files with 0 additions and 102 deletions.
1 change: 0 additions & 1 deletion extensions/amp-viewer-integration/TICKEVENTS.md
Expand Up @@ -53,4 +53,3 @@ As an example if we executed `perf.tick('label')` we assume we have a counterpar
| Load Event Start | `loadEventStart` | Time immediately before the load event of the current document is fired |
| Request Start | `requestStart` | Time immediately before the user agent starts requesting the resource from the server |
| Response Start | `responseStart` | Time immediately after the user agent's HTTP parser receives the first byte of the response from the server |
| Slow element ratio | `ser` | Percentage of elements laid out after entering viewport |
1 change: 0 additions & 1 deletion src/enums.js
Expand Up @@ -55,7 +55,6 @@ export const TickLabel = {
MESSAGING_READY: 'msr',
ON_FIRST_VISIBLE: 'ofv',
ON_LOAD: 'ol',
SLOW_ELEMENT_RATIO: 'ser',
TIME_ORIGIN: 'timeOrigin',
VIDEO_CACHE_STATE: 'vcs',
VIDEO_ERROR: 'verr',
Expand Down
5 changes: 0 additions & 5 deletions src/inabox/inabox-resources.js
Expand Up @@ -256,11 +256,6 @@ export class InaboxResources {
observer.observe(element);
}
}

/** @override */
getSlowElementRatio() {
return 0;
}
}

/**
Expand Down
27 changes: 0 additions & 27 deletions src/service/performance-impl.js
Expand Up @@ -114,12 +114,6 @@ export class Performance {
*/
this.aggregateShiftScore_ = 0;

/**
* True if the ratios have already been ticked.
* @private {boolean}
*/
this.slowElementRatioTicked_ = false;

const supportedEntryTypes =
(this.win.PerformanceObserver &&
this.win.PerformanceObserver.supportedEntryTypes) ||
Expand Down Expand Up @@ -503,7 +497,6 @@ export class Performance {
if (this.supportsLargestContentfulPaint_) {
this.tickLargestContentfulPaint_();
}
this.tickSlowElementRatio_();
}

/**
Expand Down Expand Up @@ -543,26 +536,6 @@ export class Performance {
}
}

/**
* Tick the slow element ratio.
*/
tickSlowElementRatio_() {
if (this.slowElementRatioTicked_) {
return;
}
if (!this.resources_) {
dev().error(TAG, 'Failed to tick ser due to null resources');
return;
}

this.slowElementRatioTicked_ = true;
this.tickDelta(
TickLabel.SLOW_ELEMENT_RATIO,
this.resources_.getSlowElementRatio()
);
this.flush();
}

/**
* Tick fp time based on Chromium's legacy paint timing API when
* appropriate.
Expand Down
25 changes: 0 additions & 25 deletions src/service/resources-impl.js
Expand Up @@ -208,18 +208,6 @@ export class ResourcesImpl {
this.ampdoc.getVisibilityState()
);

/**
* Number of resources that were laid out after entering viewport.
* @private {number}
*/
this.slowLayoutCount_ = 0;

/**
* Total number of laid out resources.
* @private {number}
*/
this.totalLayoutCount_ = 0;

/** @private {?IntersectionObserver} */
this.intersectionObserver_ = null;

Expand Down Expand Up @@ -833,14 +821,6 @@ export class ResourcesImpl {
}
}

/** @override */
getSlowElementRatio() {
if (this.totalLayoutCount_ === 0) {
return 0;
}
return this.slowLayoutCount_ / this.totalLayoutCount_;
}

/**
* Returns `true` when there's mutate work currently batched.
* @return {boolean}
Expand Down Expand Up @@ -1671,11 +1651,6 @@ export class ResourcesImpl {
* @private
*/
taskComplete_(task, success, opt_reason) {
this.totalLayoutCount_++;
if (task.resource.isInViewport() && this.firstVisibleTime_ >= 0) {
this.slowLayoutCount_++;
}

this.exec_.dequeue(task);
this.schedulePass(POST_TASK_PASS_DELAY_);
if (!success) {
Expand Down
6 changes: 0 additions & 6 deletions src/service/resources-interface.js
Expand Up @@ -183,11 +183,5 @@ export class ResourcesInterface {
* @return {boolean}
*/
isIntersectionExperimentOn() {}

/**
* Returns the percent of resources that were laid out after entering viewport.
* @return {number}
*/
getSlowElementRatio() {}
}
/* eslint-enable no-unused-vars */
37 changes: 0 additions & 37 deletions test/unit/test-resources.js
Expand Up @@ -463,43 +463,6 @@ describe('Resources', () => {
// The other task is not updated.
expect(task2.priority).to.equal(LayoutPriority.ADS);
});

describe('slow element ratio (ser)', () => {
const slowTask = {resource: {isInViewport: () => true}};
const fastTask = {resource: {isInViewport: () => false}};

it('No layouts --> 0', () => {
resources.firstVisibleTime_ = 1;
expect(resources.getSlowElementRatio()).equal(0);
});

it('0 slow / 1 total --> 0', () => {
resources.firstVisibleTime_ = 1;
resources.taskComplete_(fastTask);
expect(resources.getSlowElementRatio()).equal(0);
});

it('ser is 0 if page was never visible', () => {
resources.firstVisibleTime_ = -1;
resources.taskComplete_(slowTask);
expect(resources.getSlowElementRatio()).equal(0);
});

it('1 slow / 1 total --> 1', () => {
resources.firstVisibleTime_ = 1;
resources.taskComplete_(slowTask);
expect(resources.getSlowElementRatio()).equal(1);
});

it('9 slow/ 10 total --> 0.9', () => {
resources.firstVisibleTime_ = 1;
for (let i = 0; i < 9; i++) {
resources.taskComplete_(slowTask);
}
resources.taskComplete_(fastTask);
expect(resources.getSlowElementRatio()).equal(0.9);
});
});
});

describes.fakeWin(
Expand Down

0 comments on commit 3c1d10a

Please sign in to comment.