Skip to content
This repository has been archived by the owner on Jul 10, 2023. It is now read-only.

Commit

Permalink
simplify update resourceAvgDuration
Browse files Browse the repository at this point in the history
  • Loading branch information
fatihaydilek committed Aug 30, 2019
1 parent cecc05a commit 94709fe
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions src/plugins/data/invocation/Resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,13 @@ class Resource {
});
}
this.resourceDuration += resource.resourceDuration;
this.updateResourceAvgDuration(resource.resourceDuration);
this.resourceAvgDuration = Math.round(this.resourceDuration / this.resourceCount * 100) / 100;
if (resource.resourceMaxDuration > this.resourceMaxDuration) {
this.resourceMaxDuration = resource.resourceMaxDuration;
}
}
}

public updateResourceAvgDuration(newDuration: number ): void {
const differential = (newDuration - this.resourceAvgDuration) / this.resourceCount;
this.resourceAvgDuration += differential;
this.resourceAvgDuration = Math.round(this.resourceAvgDuration * 100) / 100;
}

public generateId(): string {
return `${this.resourceType.toUpperCase()}\$${this.resourceName}\$${this.resourceOperation}`;
}
Expand Down

0 comments on commit 94709fe

Please sign in to comment.