Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: general performance optimisations #383

Merged
merged 4 commits into from
Jul 28, 2024
Merged

Conversation

JoviDeCroock
Copy link
Member

@JoviDeCroock JoviDeCroock commented Jul 27, 2024

  • use an EMPTY_STR for coercion to reduce allocation of empty strings as well as for empty string checks
  • only call encodeEntities when the entity in question is a string, this removes always calling the function and an unnecessary coercion
  • ensure we leverage x = x + y rather than x += y
  • ensure we leverage our isArray helper
  • guard for some code-paths that are only possible with i.e. a class-component (avoids expensive object checks)
  • skip function type properties

Results from CI (locally saw a bit larger increases, maybe node version?)

Text:
baseline x 259.905 ops/sec ±2.52 (83 runs sampled)
current x 273.589 ops/sec ±2.15 (87 runs sampled)
Fastest is current

SearchResults:
baseline x 1,330.724 ops/sec ±3.20 (87 runs sampled)
current x 1,365.269 ops/sec ±2.88 (89 runs sampled)
Fastest is current,baseline

ColorPicker:
baseline x 6,429.806 ops/sec ±3.09 (91 runs sampled)
current x 7,311.005 ops/sec ±3.29 (86 runs sampled)
Fastest is current

Stack Depth:
baseline x 183.456 ops/sec ±4.74 (67 runs sampled)
current x 194.845 ops/sec ±3.77 (72 runs sampled)
Fastest is current,baseline

Copy link

changeset-bot bot commented Jul 27, 2024

🦋 Changeset detected

Latest commit: ec50987

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
preact-render-to-string Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Member

@marvinhagemeister marvinhagemeister left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, this is great!

@JoviDeCroock JoviDeCroock merged commit 883e02b into main Jul 28, 2024
1 check passed
@JoviDeCroock JoviDeCroock deleted the perf-optimisations branch July 28, 2024 16:34
@github-actions github-actions bot mentioned this pull request Jul 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants