Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .github/workflows/label-version-bump.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ jobs:
node-version: lts/*
cache: 'yarn'

- name: Install semver
run: yarn global add semver

- name: Detect version bump type
id: bump-type
run: |
Expand All @@ -55,6 +52,7 @@ jobs:
id: versions
if: steps.bump-type.outputs.bump-type != 'null'
run: |
npm add --global semver
OLD_VERSION=$(jq ".version" package.json -r)
NEW_VERSION=$(semver $OLD_VERSION -i ${{ steps.bump-type.outputs.bump-type }})
echo "old-version=$OLD_VERSION" >> "$GITHUB_OUTPUT"
Expand Down
68 changes: 0 additions & 68 deletions packages/rrweb-snapshot/test/css.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,74 +227,6 @@ describe('css splitter', () => {
}
expect(splitCssText(cssText, style)).toEqual(sections);
});

it(
'the second time is faster',
{
// because we're timing every so often this might flap because computers
retry: 3,
},
() => {
const cssText = fs.readFileSync(
path.resolve(__dirname, './css/benchmark.css'),
'utf8',
);

const parts = cssText.split('}');
const sections = [];
for (let i = 0; i < parts.length - 1; i++) {
if (i % 100 === 0) {
sections.push(parts[i] + '}');
} else {
sections[sections.length - 1] += parts[i] + '}';
}
}
sections[sections.length - 1] += parts[parts.length - 1];

expect(cssText.length).toEqual(sections.join('').length);

const style = JSDOM.fragment(`<style></style>`).querySelector('style');
if (style) {
sections.forEach((section) => {
style.appendChild(JSDOM.fragment(section));
});
}

// Measure the time for the first execution
const startFirst = performance.now();
const firstResult = splitCssText(cssText, style);
const endFirst = performance.now();
const firstExecutionTime = endFirst - startFirst;

expect(firstResult).toEqual(sections);

const cachedExecutionTimes = [];
for (let i = 0; i < 100; i++) {
// Measure the time for the second execution
const startSecond = performance.now();
const secondResult = splitCssText(cssText, style);
const endSecond = performance.now();

expect(secondResult).toEqual(firstResult);
const secondExecutionTime = endSecond - startSecond;
cachedExecutionTimes.push(secondExecutionTime);
}

// Assert that the second execution is faster
expect(
cachedExecutionTimes.every((time) => time < firstExecutionTime),
).toBe(true);

// Optional: Log the execution times for debugging
console.log(`First execution time: ${firstExecutionTime}ms`);
console.log(
`Average execution time for the second execution: ${
cachedExecutionTimes.reduce((a, b) => a + b) /
cachedExecutionTimes.length
}ms`,
);
},
);
});

describe('applyCssSplits css rejoiner', function () {
Expand Down
Loading