Skip to content

Commit

Permalink
fix: ignore minor gas changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sakulstra committed Nov 18, 2024
1 parent e70b73e commit cdd2cce
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions dist/action.js
Original file line number Diff line number Diff line change
Expand Up @@ -23974,6 +23974,7 @@ function findFunction(fn, snapshot) {
function formatValue(before, after) {
if (!before || after === before) return after;
const diff = (after - before) / Math.abs(before) * 100;
if (Math.abs(diff) < 0.1) return after;
return `<sup title="${before}">${diff > 0 ? UP : DOWN}${new Intl.NumberFormat(
"en-US",
{
Expand Down
1 change: 1 addition & 0 deletions dist/action.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -23979,6 +23979,7 @@ function findFunction(fn, snapshot) {
function formatValue(before, after) {
if (!before || after === before) return after;
const diff = (after - before) / Math.abs(before) * 100;
if (Math.abs(diff) < 0.1) return after;
return `<sup title="${before}">${diff > 0 ? UP : DOWN}${new Intl.NumberFormat(
"en-US",
{
Expand Down
1 change: 1 addition & 0 deletions dist/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ function findFunction(fn, snapshot) {
function formatValue(before, after) {
if (!before || after === before) return after;
const diff = (after - before) / Math.abs(before) * 100;
if (Math.abs(diff) < 0.1) return after;
return `<sup title="${before}">${diff > 0 ? UP : DOWN}${new Intl.NumberFormat(
"en-US",
{
Expand Down
1 change: 1 addition & 0 deletions dist/lib.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ function findFunction(fn, snapshot) {
function formatValue(before, after) {
if (!before || after === before) return after;
const diff = (after - before) / Math.abs(before) * 100;
if (Math.abs(diff) < 0.1) return after;
return `<sup title="${before}">${diff > 0 ? UP : DOWN}${new Intl.NumberFormat(
"en-US",
{
Expand Down
2 changes: 1 addition & 1 deletion mocks/gas.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"min": 1024,
"mean": 1024,
"median": 1024,
"max": 1024
"max": 1025
}
}
},
Expand Down
5 changes: 3 additions & 2 deletions src/__snapshots__/lib.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ exports[`lib > should generate a well formatted report with empty root 1`] = `
| Method | min | mean | median | max | calls |
| --- | ---: | ---: | ---: | ---: | ---: |
create(bytes32,bytes) | 286388 | 296666 | 287062 | 397068 | 6 |
predictAddress(address,bytes32) | 1024 | 1024 | 1024 | 1024 | 6 |
predictAddress(address,bytes32) | 1024 | 1024 | 1024 | 1025 | 6 |
### [ProxyAdmin](https://github.com/src/contracts/transparent-proxy/ProxyAdmin.sol)
Expand Down Expand Up @@ -75,6 +75,7 @@ exports[`lib > should generate a well formatted report with existing root & skip
| Method | min | mean | median | max | calls |
| --- | ---: | ---: | ---: | ---: | ---: |
create(bytes32,bytes) | <sup title="296388">↓-3.4%</sup>286388 | 296666 | 287062 | <sup title="297068">↑34%</sup>397068 | 6 |
predictAddress(address,bytes32) | 1024 | 1024 | 1024 | 1025 | 6 |
### [TransparentProxyFactory](https://github.com/src/contracts/transparent-proxy/TransparentProxyFactory.sol)
Expand All @@ -92,7 +93,7 @@ exports[`lib > should generate a well formatted report with existing root 1`] =
| Method | min | mean | median | max | calls |
| --- | ---: | ---: | ---: | ---: | ---: |
create(bytes32,bytes) | <sup title="296388">↓-3.4%</sup>286388 | 296666 | 287062 | <sup title="297068">↑34%</sup>397068 | 6 |
predictAddress(address,bytes32) | 1024 | 1024 | 1024 | 1024 | 6 |
predictAddress(address,bytes32) | 1024 | 1024 | 1024 | 1025 | 6 |
### [ProxyAdmin](https://github.com/src/contracts/transparent-proxy/ProxyAdmin.sol)
Expand Down
2 changes: 2 additions & 0 deletions src/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ function findFunction(
function formatValue(before: number | undefined, after: number) {
if (!before || after === before) return after;
const diff = ((after - before) / Math.abs(before)) * 100;
// if diff is below threshold, showing the diff is more noise than signal
if (Math.abs(diff) < 0.1) return after;
return `<sup title="${before}">${diff > 0 ? UP : DOWN}${new Intl.NumberFormat(
"en-US",
{
Expand Down

0 comments on commit cdd2cce

Please sign in to comment.