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

Add support for new String() as a child #4152

Merged
merged 1 commit into from
Oct 9, 2023

Conversation

appsforartists
Copy link
Contributor

'abc'.constructor === String

Therefore, testing the constructor is a more inclusive way of finding strings. It allows new String('hi') and 'hi' to be treated equally.

Note: this improves interchangability with React.

Fixes #4151

@github-actions
Copy link

github-actions bot commented Oct 4, 2023

📊 Tachometer Benchmark Results

Summary

duration

  • 02_replace1k: unsure 🔍 -4% - +3% (-5.77ms - +3.90ms)
    preact-local vs preact-main
  • 03_update10th1k_x16: unsure 🔍 -6% - +1% (-3.23ms - +0.31ms)
    preact-local vs preact-main
  • 07_create10k: unsure 🔍 -1% - +1% (-15.54ms - +10.41ms)
    preact-local vs preact-main
  • filter_list: unsure 🔍 -4% - +2% (-1.23ms - +0.58ms)
    preact-local vs preact-main
  • hydrate1k: unsure 🔍 -0% - +1% (-0.62ms - +1.66ms)
    preact-local vs preact-main
  • many_updates: unsure 🔍 -2% - +2% (-0.60ms - +0.50ms)
    preact-local vs preact-main
  • text_update: unsure 🔍 -1% - +11% (-0.04ms - +0.41ms)
    preact-local vs preact-main
  • todo: slower ❌ 0% - 2% (0.21ms - 1.08ms)
    preact-local vs preact-main

usedJSHeapSize

  • 02_replace1k: unsure 🔍 -0% - +0% (-0.00ms - +0.01ms)
    preact-local vs preact-main
  • 03_update10th1k_x16: unsure 🔍 -0% - +0% (-0.01ms - +0.00ms)
    preact-local vs preact-main
  • 07_create10k: unsure 🔍 -0% - +0% (-0.00ms - +0.01ms)
    preact-local vs preact-main
  • filter_list: unsure 🔍 -2% - +2% (-0.03ms - +0.02ms)
    preact-local vs preact-main
  • hydrate1k: unsure 🔍 -0% - +0% (-0.01ms - +0.01ms)
    preact-local vs preact-main
  • many_updates: faster ✔ 0% - 1% (0.00ms - 0.04ms)
    preact-local vs preact-main
  • text_update: unsure 🔍 -4% - +2% (-0.03ms - +0.01ms)
    preact-local vs preact-main
  • todo: unsure 🔍 -0% - +0% (-0.00ms - +0.00ms)
    preact-local vs preact-main

Results

02_replace1k

duration

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main139.25ms - 145.75ms-unsure 🔍
-3% - +4%
-3.90ms - +5.77ms
unsure 🔍
-3% - +3%
-4.79ms - +4.91ms
preact-local137.98ms - 145.14msunsure 🔍
-4% - +3%
-5.77ms - +3.90ms
-unsure 🔍
-4% - +3%
-5.95ms - +4.21ms
preact-hooks138.83ms - 146.04msunsure 🔍
-3% - +3%
-4.91ms - +4.79ms
unsure 🔍
-3% - +4%
-4.21ms - +5.95ms
-

usedJSHeapSize

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main3.29ms - 3.30ms-unsure 🔍
-0% - +0%
-0.01ms - +0.00ms
faster ✔
0% - 1%
0.02ms - 0.03ms
preact-local3.29ms - 3.30msunsure 🔍
-0% - +0%
-0.00ms - +0.01ms
-faster ✔
0% - 1%
0.01ms - 0.02ms
preact-hooks3.31ms - 3.32msslower ❌
0% - 1%
0.02ms - 0.03ms
slower ❌
0% - 1%
0.01ms - 0.02ms
-

run-warmup-0

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main43.91ms - 45.68ms-faster ✔
0% - 6%
0.04ms - 2.67ms
faster ✔
3% - 8%
1.49ms - 3.89ms
preact-local45.17ms - 47.12msslower ❌
0% - 6%
0.04ms - 2.67ms
-faster ✔
0% - 5%
0.07ms - 2.60ms
preact-hooks46.68ms - 48.29msslower ❌
3% - 9%
1.49ms - 3.89ms
slower ❌
0% - 6%
0.07ms - 2.60ms
-

run-warmup-1

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main54.27ms - 56.57ms-unsure 🔍
-4% - +2%
-2.18ms - +1.16ms
unsure 🔍
-6% - +0%
-3.45ms - +0.09ms
preact-local54.72ms - 57.15msunsure 🔍
-2% - +4%
-1.16ms - +2.18ms
-unsure 🔍
-5% - +1%
-2.98ms - +0.65ms
preact-hooks55.75ms - 58.45msunsure 🔍
-0% - +6%
-0.09ms - +3.45ms
unsure 🔍
-1% - +5%
-0.65ms - +2.98ms
-

run-warmup-2

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main42.79ms - 44.34ms-unsure 🔍
-4% - +1%
-1.71ms - +0.65ms
unsure 🔍
-4% - +1%
-1.89ms - +0.53ms
preact-local43.20ms - 44.99msunsure 🔍
-2% - +4%
-0.65ms - +1.71ms
-unsure 🔍
-3% - +3%
-1.44ms - +1.14ms
preact-hooks43.31ms - 45.18msunsure 🔍
-1% - +4%
-0.53ms - +1.89ms
unsure 🔍
-3% - +3%
-1.14ms - +1.44ms
-

run-warmup-3

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main37.52ms - 38.45ms-unsure 🔍
-3% - +2%
-1.11ms - +0.68ms
unsure 🔍
-4% - +0%
-1.70ms - +0.16ms
preact-local37.43ms - 38.97msunsure 🔍
-2% - +3%
-0.68ms - +1.11ms
-unsure 🔍
-4% - +1%
-1.67ms - +0.55ms
preact-hooks37.95ms - 39.56msunsure 🔍
-0% - +4%
-0.16ms - +1.70ms
unsure 🔍
-1% - +4%
-0.55ms - +1.67ms
-

run-warmup-4

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main46.18ms - 47.23ms-unsure 🔍
-2% - +2%
-0.72ms - +0.97ms
unsure 🔍
-2% - +2%
-0.81ms - +0.96ms
preact-local45.92ms - 47.24msunsure 🔍
-2% - +2%
-0.97ms - +0.72ms
-unsure 🔍
-2% - +2%
-1.02ms - +0.92ms
preact-hooks45.92ms - 47.34msunsure 🔍
-2% - +2%
-0.96ms - +0.81ms
unsure 🔍
-2% - +2%
-0.92ms - +1.02ms
-

run-final

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main38.19ms - 44.25ms-unsure 🔍
-15% - +6%
-6.39ms - +2.67ms
unsure 🔍
-17% - +3%
-7.72ms - +1.39ms
preact-local39.71ms - 46.44msunsure 🔍
-7% - +16%
-2.67ms - +6.39ms
-unsure 🔍
-14% - +8%
-6.09ms - +3.48ms
preact-hooks40.98ms - 47.78msunsure 🔍
-4% - +19%
-1.39ms - +7.72ms
unsure 🔍
-8% - +14%
-3.48ms - +6.09ms
-
03_update10th1k_x16

duration

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main52.27ms - 54.82ms-unsure 🔍
-1% - +6%
-0.31ms - +3.23ms
unsure 🔍
-1% - +5%
-0.56ms - +2.84ms
preact-local50.87ms - 53.31msunsure 🔍
-6% - +1%
-3.23ms - +0.31ms
-unsure 🔍
-4% - +3%
-1.99ms - +1.34ms
preact-hooks51.29ms - 53.54msunsure 🔍
-5% - +1%
-2.84ms - +0.56ms
unsure 🔍
-3% - +4%
-1.34ms - +1.99ms
-

usedJSHeapSize

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main3.25ms - 3.26ms-unsure 🔍
-0% - +0%
-0.00ms - +0.01ms
faster ✔
0% - 1%
0.01ms - 0.02ms
preact-local3.25ms - 3.26msunsure 🔍
-0% - +0%
-0.01ms - +0.00ms
-faster ✔
0% - 1%
0.02ms - 0.03ms
preact-hooks3.27ms - 3.28msslower ❌
0% - 1%
0.01ms - 0.02ms
slower ❌
0% - 1%
0.02ms - 0.03ms
-
07_create10k

duration

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main1467.57ms - 1485.35ms-unsure 🔍
-1% - +1%
-10.41ms - +15.54ms
unsure 🔍
-1% - +1%
-9.23ms - +12.94ms
preact-local1464.44ms - 1483.35msunsure 🔍
-1% - +1%
-15.54ms - +10.41ms
-unsure 🔍
-1% - +1%
-12.25ms - +10.84ms
preact-hooks1467.98ms - 1481.23msunsure 🔍
-1% - +1%
-12.94ms - +9.23ms
unsure 🔍
-1% - +1%
-10.84ms - +12.25ms
-

usedJSHeapSize

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main25.91ms - 25.91ms-unsure 🔍
-0% - +0%
-0.01ms - +0.00ms
unsure 🔍
-0% - -0%
-0.03ms - -0.02ms
preact-local25.91ms - 25.91msunsure 🔍
-0% - +0%
-0.00ms - +0.01ms
-unsure 🔍
-0% - -0%
-0.02ms - -0.01ms
preact-hooks25.92ms - 25.93msunsure 🔍
+0% - +0%
+0.02ms - +0.03ms
unsure 🔍
+0% - +0%
+0.01ms - +0.02ms
-
filter_list

duration

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main28.79ms - 30.17ms-unsure 🔍
-2% - +4%
-0.58ms - +1.23ms
unsure 🔍
-2% - +4%
-0.67ms - +1.14ms
preact-local28.57ms - 29.74msunsure 🔍
-4% - +2%
-1.23ms - +0.58ms
-unsure 🔍
-3% - +3%
-0.92ms - +0.74ms
preact-hooks28.66ms - 29.83msunsure 🔍
-4% - +2%
-1.14ms - +0.67ms
unsure 🔍
-3% - +3%
-0.74ms - +0.92ms
-

usedJSHeapSize

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main1.39ms - 1.43ms-unsure 🔍
-2% - +2%
-0.02ms - +0.03ms
unsure 🔍
-4% - +0%
-0.05ms - +0.00ms
preact-local1.38ms - 1.42msunsure 🔍
-2% - +2%
-0.03ms - +0.02ms
-faster ✔
0% - 4%
0.00ms - 0.06ms
preact-hooks1.41ms - 1.45msunsure 🔍
-0% - +4%
-0.00ms - +0.05ms
slower ❌
0% - 4%
0.00ms - 0.06ms
-
hydrate1k

duration

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main129.73ms - 131.19ms-unsure 🔍
-1% - +0%
-1.66ms - +0.62ms
unsure 🔍
-1% - +1%
-1.25ms - +0.98ms
preact-local130.10ms - 131.85msunsure 🔍
-0% - +1%
-0.62ms - +1.66ms
-unsure 🔍
-1% - +1%
-0.83ms - +1.60ms
preact-hooks129.75ms - 131.43msunsure 🔍
-1% - +1%
-0.98ms - +1.25ms
unsure 🔍
-1% - +1%
-1.60ms - +0.83ms
-

usedJSHeapSize

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main6.05ms - 6.07ms-unsure 🔍
-0% - +0%
-0.01ms - +0.01ms
unsure 🔍
-0% - -0%
-0.02ms - -0.01ms
preact-local6.05ms - 6.07msunsure 🔍
-0% - +0%
-0.01ms - +0.01ms
-unsure 🔍
-0% - -0%
-0.03ms - -0.01ms
preact-hooks6.07ms - 6.08msunsure 🔍
+0% - +0%
+0.01ms - +0.02ms
unsure 🔍
+0% - +0%
+0.01ms - +0.03ms
-
many_updates

duration

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main26.70ms - 27.56ms-unsure 🔍
-2% - +2%
-0.50ms - +0.60ms
unsure 🔍
-5% - +0%
-1.43ms - +0.09ms
preact-local26.74ms - 27.42msunsure 🔍
-2% - +2%
-0.60ms - +0.50ms
-faster ✔
0% - 5%
0.01ms - 1.43ms
preact-hooks27.17ms - 28.42msunsure 🔍
-0% - +5%
-0.09ms - +1.43ms
slower ❌
0% - 5%
0.01ms - 1.43ms
-

usedJSHeapSize

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main4.44ms - 4.47ms-unsure 🔍
-0% - +1%
+0.00ms - +0.04ms
unsure 🔍
-1% - +0%
-0.03ms - +0.01ms
preact-local4.42ms - 4.45msfaster ✔
0% - 1%
0.00ms - 0.04ms
-faster ✔
0% - 1%
0.01ms - 0.05ms
preact-hooks4.45ms - 4.48msunsure 🔍
-0% - +1%
-0.01ms - +0.03ms
slower ❌
0% - 1%
0.01ms - 0.05ms
-
text_update

duration

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main3.64ms - 3.95ms-unsure 🔍
-10% - +1%
-0.41ms - +0.04ms
faster ✔
7% - 17%
0.28ms - 0.75ms
preact-local3.82ms - 4.14msunsure 🔍
-1% - +11%
-0.04ms - +0.41ms
-faster ✔
2% - 13%
0.10ms - 0.57ms
preact-hooks4.14ms - 4.49msslower ❌
7% - 20%
0.28ms - 0.75ms
slower ❌
2% - 15%
0.10ms - 0.57ms
-

usedJSHeapSize

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main0.67ms - 0.70ms-unsure 🔍
-2% - +4%
-0.01ms - +0.03ms
unsure 🔍
-4% - +2%
-0.02ms - +0.01ms
preact-local0.66ms - 0.69msunsure 🔍
-4% - +2%
-0.03ms - +0.01ms
-unsure 🔍
-5% - +1%
-0.03ms - +0.00ms
preact-hooks0.68ms - 0.70msunsure 🔍
-2% - +4%
-0.01ms - +0.02ms
unsure 🔍
-1% - +5%
-0.00ms - +0.03ms
-
todo

duration

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main47.05ms - 47.79ms-faster ✔
0% - 2%
0.21ms - 1.08ms
faster ✔
3% - 5%
1.27ms - 2.28ms
preact-local47.85ms - 48.28msslower ❌
0% - 2%
0.21ms - 1.08ms
-faster ✔
1% - 3%
0.72ms - 1.54ms
preact-hooks48.85ms - 49.54msslower ❌
3% - 5%
1.27ms - 2.28ms
slower ❌
1% - 3%
0.72ms - 1.54ms
-

usedJSHeapSize

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main0.81ms - 0.81ms-unsure 🔍
-0% - +0%
-0.00ms - +0.00ms
faster ✔
3% - 3%
0.02ms - 0.02ms
preact-local0.81ms - 0.81msunsure 🔍
-0% - +0%
-0.00ms - +0.00ms
-faster ✔
3% - 3%
0.02ms - 0.02ms
preact-hooks0.83ms - 0.83msslower ❌
3% - 3%
0.02ms - 0.02ms
slower ❌
3% - 3%
0.02ms - 0.02ms
-

tachometer-reporter-action v2 for Benchmarks

@appsforartists
Copy link
Contributor Author

Supporting String was a simple change. I tried also supporting toString(), but that broke a lot of tests. Presumably there are expected non-string children that have toString defined.

For future edification, here is the test that would have supported that:

	it('should render an object that can be coerced toString()', () => {
		class CoercedStringComponent extends Component {
			render() {
				return {
					toString: () => 'Hi from toString()!.',
				}
			}
		}

		render(<CoercedStringComponent />, scratch);
		expect(scratch.innerHTML).to.equal('Hi from toString()!.');
	});

@coveralls
Copy link

coveralls commented Oct 4, 2023

Coverage Status

coverage: 99.293%. remained the same when pulling e41b117 on appsforartists:new-string into 9c5a82e on preactjs:main.

@JoviDeCroock JoviDeCroock merged commit 600d8cf into preactjs:main Oct 9, 2023
13 checks passed
@JoviDeCroock JoviDeCroock mentioned this pull request Nov 3, 2023
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.

<div>{ new String('hi') }</div> renders blank
3 participants