Skip to content

Commit

Permalink
Use createRoot on benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
pirelenito committed Nov 14, 2023
1 parent 8b542ed commit d87e4ed
Show file tree
Hide file tree
Showing 15 changed files with 96 additions and 36 deletions.
8 changes: 6 additions & 2 deletions examples/benchmarking/src/listMemoFacet.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useFacetState, Facet, useFacetMap, useFacetEffect, NO_VALUE, Map } from '@react-facet/core'
import { render } from '@react-facet/dom-fiber'
import { createRoot } from '@react-facet/dom-fiber'
import React, { useEffect } from 'react'

interface Data {
Expand Down Expand Up @@ -103,4 +103,8 @@ const dataEqualityCheck = () => {
}

document.body.innerHTML = '<div id="root"/>'
render(<Performance />, document.getElementById('root'))
const element = document.getElementById('root')
if (element != null) {

Check failure on line 107 in examples/benchmarking/src/listMemoFacet.tsx

View workflow job for this annotation

GitHub Actions / lint (ubuntu-latest)

Expected '!==' and instead saw '!='
const root = createRoot(element)
root.render(<Performance />)
}
8 changes: 6 additions & 2 deletions examples/benchmarking/src/listMemoState.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { render } from 'react-dom'
import { createRoot } from 'react-dom/client'
import React, { useEffect, useState, memo } from 'react'

interface Data {
Expand Down Expand Up @@ -65,4 +65,8 @@ const ListItem = memo(({ health, name }: Data) => {
const randomWork = (name: string | number) => Math.random()

document.body.innerHTML = '<div id="root"/>'
render(<Performance />, document.getElementById('root'))
const element = document.getElementById('root')
if (element != null) {

Check failure on line 69 in examples/benchmarking/src/listMemoState.tsx

View workflow job for this annotation

GitHub Actions / lint (ubuntu-latest)

Expected '!==' and instead saw '!='
const root = createRoot(element)
root.render(<Performance />)
}
8 changes: 6 additions & 2 deletions examples/benchmarking/src/markerFacet.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useEffect } from 'react'
import { render } from '@react-facet/dom-fiber'
import { createRoot } from '@react-facet/dom-fiber'
import { useFacetState, Facet, useFacetMap, NO_VALUE, Map } from '@react-facet/core'
import { times } from 'ramda'

Expand Down Expand Up @@ -63,4 +63,8 @@ function Performance() {
}

document.body.innerHTML = '<div id="root"/>'
render(<Performance />, document.getElementById('root'))
const element = document.getElementById('root')
if (element != null) {

Check failure on line 67 in examples/benchmarking/src/markerFacet.tsx

View workflow job for this annotation

GitHub Actions / lint (ubuntu-latest)

Expected '!==' and instead saw '!='
const root = createRoot(element)
root.render(<Performance />)
}
8 changes: 6 additions & 2 deletions examples/benchmarking/src/markerFacetNumber.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useEffect } from 'react'
import { render } from '@react-facet/dom-fiber'
import { createRoot } from '@react-facet/dom-fiber'
import { useFacetState, Facet, useFacetMap, NO_VALUE, Map } from '@react-facet/core'
import { times } from 'ramda'

Expand Down Expand Up @@ -63,4 +63,8 @@ function Performance() {
}

document.body.innerHTML = '<div id="root"/>'
render(<Performance />, document.getElementById('root'))
const element = document.getElementById('root')
if (element != null) {

Check failure on line 67 in examples/benchmarking/src/markerFacetNumber.tsx

View workflow job for this annotation

GitHub Actions / lint (ubuntu-latest)

Expected '!==' and instead saw '!='
const root = createRoot(element)
root.render(<Performance />)
}
8 changes: 6 additions & 2 deletions examples/benchmarking/src/markerState.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { render } from 'react-dom'
import { createRoot } from 'react-dom/client'
import React, { useEffect, useState } from 'react'
import { times } from 'ramda'

Expand Down Expand Up @@ -61,4 +61,8 @@ function Performance() {
}

document.body.innerHTML = '<div id="root"/>'
render(<Performance />, document.getElementById('root'))
const element = document.getElementById('root')
if (element != null) {

Check failure on line 65 in examples/benchmarking/src/markerState.tsx

View workflow job for this annotation

GitHub Actions / lint (ubuntu-latest)

Expected '!==' and instead saw '!='
const root = createRoot(element)
root.render(<Performance />)
}
8 changes: 6 additions & 2 deletions examples/benchmarking/src/mountFacetDomFiber.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { render } from '@react-facet/dom-fiber'
import { createRoot } from '@react-facet/dom-fiber'
import { times } from 'ramda'
import React, { useEffect, useState } from 'react'

Expand Down Expand Up @@ -54,4 +54,8 @@ const ComplexComponent = ({ value }: { value: number }) => {
}

document.body.innerHTML = '<div id="root"/>'
render(<Performance />, document.getElementById('root'))
const element = document.getElementById('root')
if (element != null) {

Check failure on line 58 in examples/benchmarking/src/mountFacetDomFiber.tsx

View workflow job for this annotation

GitHub Actions / lint (ubuntu-latest)

Expected '!==' and instead saw '!='
const root = createRoot(element)
root.render(<Performance />)
}
8 changes: 6 additions & 2 deletions examples/benchmarking/src/mountReactDom.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { render } from 'react-dom'
import { createRoot } from 'react-dom/client'
import { times } from 'ramda'
import React, { useEffect, useState } from 'react'

Expand Down Expand Up @@ -54,4 +54,8 @@ const ComplexComponent = ({ value }: { value: number }) => {
}

document.body.innerHTML = '<div id="root"/>'
render(<Performance />, document.getElementById('root'))
const element = document.getElementById('root')
if (element != null) {

Check failure on line 58 in examples/benchmarking/src/mountReactDom.tsx

View workflow job for this annotation

GitHub Actions / lint (ubuntu-latest)

Expected '!==' and instead saw '!='
const root = createRoot(element)
root.render(<Performance />)
}
10 changes: 7 additions & 3 deletions examples/benchmarking/src/overheadFacet.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { render } from '@react-facet/dom-fiber'
import { createRoot } from '@react-facet/dom-fiber'
import { useFacetState, useFacetEffect } from '@react-facet/core'
import React, { useEffect } from 'react'

Expand Down Expand Up @@ -31,5 +31,9 @@ function Performance() {
return null
}

document.body.innerHTML = `<div id="root"></div>`
render(<Performance />, document.getElementById('root'))
document.body.innerHTML = '<div id="root"/>'
const element = document.getElementById('root')
if (element != null) {

Check failure on line 36 in examples/benchmarking/src/overheadFacet.tsx

View workflow job for this annotation

GitHub Actions / lint (ubuntu-latest)

Expected '!==' and instead saw '!='
const root = createRoot(element)
root.render(<Performance />)
}
10 changes: 7 additions & 3 deletions examples/benchmarking/src/overheadState.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { render } from 'react-dom'
import { createRoot } from 'react-dom/client'
import React, { useEffect, useState } from 'react'

function Performance() {
Expand Down Expand Up @@ -26,5 +26,9 @@ function Performance() {
return null
}

document.body.innerHTML = `<div id="root"></div>`
render(<Performance />, document.getElementById('root'))
document.body.innerHTML = '<div id="root"/>'
const element = document.getElementById('root')
if (element != null) {

Check failure on line 31 in examples/benchmarking/src/overheadState.tsx

View workflow job for this annotation

GitHub Actions / lint (ubuntu-latest)

Expected '!==' and instead saw '!='
const root = createRoot(element)
root.render(<Performance />)
}
12 changes: 8 additions & 4 deletions examples/benchmarking/src/progressBarFacet.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useEffect } from 'react'
import { useFacetMap, Facet, useFacetState } from '@react-facet/core'
import { render } from '@react-facet/dom-fiber'
import { createRoot } from '@react-facet/dom-fiber'

const ProgressBar = ({ progress }: { progress: Facet<number> }) => {
const width = useFacetMap((progress) => `${progress * 20}px`, [], [progress])
Expand All @@ -18,7 +18,7 @@ const ProgressBar = ({ progress }: { progress: Facet<number> }) => {
)
}

const App = () => {
const Performance = () => {
const [progress, setProgress] = useFacetState(0)

useEffect(() => {
Expand All @@ -39,5 +39,9 @@ const App = () => {
return <ProgressBar progress={progress} />
}

document.body.innerHTML = `<div id="root"></div>`
render(<App />, document.getElementById('root'))
document.body.innerHTML = '<div id="root"/>'
const element = document.getElementById('root')
if (element != null) {

Check failure on line 44 in examples/benchmarking/src/progressBarFacet.tsx

View workflow job for this annotation

GitHub Actions / lint (ubuntu-latest)

Expected '!==' and instead saw '!='
const root = createRoot(element)
root.render(<Performance />)
}
12 changes: 8 additions & 4 deletions examples/benchmarking/src/progressBarState.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useEffect, useState } from 'react'
import { render } from 'react-dom'
import { createRoot } from 'react-dom/client'

const ProgressBar = ({ progress }: { progress: number }) => {
const width = `${progress * 20}px`
Expand All @@ -17,7 +17,7 @@ const ProgressBar = ({ progress }: { progress: number }) => {
)
}

const App = () => {
const Performance = () => {
const [progress, setProgress] = useState(0)

useEffect(() => {
Expand All @@ -38,5 +38,9 @@ const App = () => {
return <ProgressBar progress={progress} />
}

document.body.innerHTML = `<div id="root"></div>`
render(<App />, document.getElementById('root'))
document.body.innerHTML = '<div id="root"/>'
const element = document.getElementById('root')
if (element != null) {
const root = createRoot(element)
root.render(<Performance />)
}
8 changes: 6 additions & 2 deletions examples/benchmarking/src/toggleRealisticClassFacet.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { render } from '@react-facet/dom-fiber'
import { createRoot } from '@react-facet/dom-fiber'
import { useFacetState } from '@react-facet/core'
import React, { useEffect } from 'react'

Expand Down Expand Up @@ -59,4 +59,8 @@ document.body.innerHTML = `
</style>
`

render(<Performance />, document.getElementById('root'))
const element = document.getElementById('root')
if (element != null) {
const root = createRoot(element)
root.render(<Performance />)
}
8 changes: 6 additions & 2 deletions examples/benchmarking/src/toggleRealisticClassState.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { render } from 'react-dom'
import { createRoot } from 'react-dom/client'
import React, { useEffect, useState } from 'react'

function Performance() {
Expand Down Expand Up @@ -58,4 +58,8 @@ document.body.innerHTML = `
</style>
`

render(<Performance />, document.getElementById('root'))
const element = document.getElementById('root')
if (element != null) {
const root = createRoot(element)
root.render(<Performance />)
}
8 changes: 6 additions & 2 deletions examples/benchmarking/src/toggleSimpleClassFacet.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { render } from '@react-facet/dom-fiber'
import { createRoot } from '@react-facet/dom-fiber'
import { useFacetState } from '@react-facet/core'
import React, { useEffect } from 'react'

Expand Down Expand Up @@ -37,4 +37,8 @@ document.body.innerHTML = `
</style>
`

render(<Performance />, document.getElementById('root'))
const element = document.getElementById('root')
if (element != null) {
const root = createRoot(element)
root.render(<Performance />)
}
8 changes: 6 additions & 2 deletions examples/benchmarking/src/toggleSimpleClassState.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { render } from 'react-dom'
import { createRoot } from 'react-dom/client'
import React, { useEffect, useState } from 'react'

function Performance() {
Expand Down Expand Up @@ -36,4 +36,8 @@ document.body.innerHTML = `
</style>
`

render(<Performance />, document.getElementById('root'))
const element = document.getElementById('root')
if (element != null) {
const root = createRoot(element)
root.render(<Performance />)
}

0 comments on commit d87e4ed

Please sign in to comment.