nolanlawson / emoji-picker-element

A lightweight emoji picker for the modern web
https://nolanlawson.github.io/emoji-picker-element/
Apache License 2.0
1.49k stars 85 forks source link

perf: avoid recreating excessive empty objects #300

Closed nolanlawson closed 1 year ago

nolanlawson commented 1 year ago

Avoids some memory churn by not recreating empty objects and arrays in several places.

This introduces some risk in that we might leak these objects outside of the picker/database, and if people mutate them, then they could change the behavior. But people might already have a bad time if they mutate the objects returned from the database/picker – it's not something I've tested in the past.

github-actions[bot] commented 1 year ago

📊 Tachometer Benchmark Results

Summary

benchmark-total

  • emoji-picker-element-database-interactions: unsure 🔍 -3% - +5% (-3.55ms - +6.47ms)
    this-change vs tip-of-tree
  • emoji-picker-element-first-load: unsure 🔍 -3% - +9% (-1.64ms - +5.40ms)
    this-change vs tip-of-tree
  • emoji-picker-element-second-load: unsure 🔍 -9% - +4% (-5.28ms - +2.57ms)
    this-change vs tip-of-tree

Results

emoji-picker-element-database-interactions
  • Browser: chrome-headless 108.0.5359.98
  • Sample size: 50
  • Built by: Benchmarks #187
  • Commit: 20984b1
VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
this-change
139.27ms - 147.39ms-unsure 🔍
-3% - +5%
-3.55ms - +6.47ms
tip-of-tree
tip-of-tree
138.94ms - 144.80msunsure 🔍
-4% - +2%
-6.47ms - +3.55ms
-
emoji-picker-element-first-load
  • Browser: chrome-headless 108.0.5359.98
  • Sample size: 90
  • Built by: Benchmarks #187
  • Commit: 20984b1
VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
this-change
57.28ms - 62.43ms-unsure 🔍
-3% - +9%
-1.64ms - +5.40ms
tip-of-tree
tip-of-tree
55.57ms - 60.38msunsure 🔍
-9% - +3%
-5.40ms - +1.64ms
-
emoji-picker-element-second-load
  • Browser: chrome-headless 108.0.5359.98
  • Sample size: 80
  • Built by: Benchmarks #187
  • Commit: 20984b1
VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
this-change
56.16ms - 61.72ms-unsure 🔍
-9% - +4%
-5.28ms - +2.57ms
tip-of-tree
tip-of-tree
57.53ms - 63.06msunsure 🔍
-4% - +9%
-2.57ms - +5.28ms
-

tachometer-reporter-action v2 for Benchmarks

github-actions[bot] commented 1 year ago

Size Change: +40 B (0%)

Total Size: 41.8 kB

Filename Size Change
./bundle.js 41.8 kB +40 B (0%)

compressed-size-action

nolanlawson commented 1 year ago

Adds complexity and code for unclear benefit