Skip to content

Commit 9f050e6

Browse files
committed
refactor: improve benchmark randomly between v5 and v6 order
1 parent c84a718 commit 9f050e6

11 files changed

Lines changed: 128 additions & 82 deletions

File tree

benchmarks/run-benchmark.mjs

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const counts = `${args.counts ?? '50,100,500,2000,5000,10000,25000'}`
2727
const timeoutMs = Number(args.timeoutMs ?? 1200)
2828
const repeats = Number(args.repeats ?? 5)
2929
const warmups = Number(args.warmups ?? 1)
30-
const executablePath = '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'
30+
const executablePath = args.executablePath ?? null
3131
const workerId = args.worker ? String(args.worker) : null
3232
const runLabel = args.label ? String(args.label) : null
3333
const cacheDir = path.resolve(args.cacheDir ?? path.join(__dirname, '.cache'))
@@ -160,11 +160,15 @@ async function main() {
160160
await ensureFixtureBundle()
161161
logProgress('Launching headless Chrome')
162162

163-
const browser = await chromium.launch({
164-
executablePath,
163+
const launchOptions = {
165164
headless: true,
166165
args: ['--enable-precise-memory-info', '--js-flags=--expose-gc'],
167-
})
166+
}
167+
if (executablePath) {
168+
launchOptions.executablePath = executablePath
169+
}
170+
171+
const browser = await chromium.launch(launchOptions)
168172

169173
try {
170174
const page = await browser.newPage()
@@ -224,10 +228,21 @@ async function main() {
224228
)
225229
}
226230

227-
const v5 = await runVersion('v5')
228-
logProgress('Completed V5 run')
229-
const v6 = await runVersion('v6')
230-
logProgress('Completed V6 run')
231+
const versions = ['v5', 'v6']
232+
// Randomize execution order to avoid first-run bias
233+
if (Math.random() < 0.5) {
234+
versions.reverse()
235+
}
236+
logProgress(`Execution order: ${versions.join(' → ')}`)
237+
238+
const results = {}
239+
for (const version of versions) {
240+
results[version] = await runVersion(version)
241+
logProgress(`Completed ${version.toUpperCase()} run`)
242+
}
243+
244+
const v5 = results.v5
245+
const v6 = results.v6
231246

232247
const summary = counts.map((count) => {
233248
const v5Samples = v5.samplesByCount.filter((sample) => sample.count === count)

benchmarks/run-scaling-series.mjs

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -161,22 +161,26 @@ async function runTasksInParallel(tasks, totalWorkers) {
161161
`${workerLabel} starting pass ${task.runNumber}/${tasks.length} (${completedTasks}/${tasks.length} completed)`,
162162
)
163163

164-
await runCommand(
165-
'node',
166-
[
167-
'./benchmarks/run-benchmark.mjs',
168-
'--worker',
169-
String(workerNumber),
170-
'--label',
171-
task.label,
172-
'--cacheDir',
173-
cacheDir,
174-
...passthroughArgs,
175-
],
176-
{
177-
label: `${workerLabel} ${task.label}`,
178-
},
179-
)
164+
try {
165+
await runCommand(
166+
'node',
167+
[
168+
'./benchmarks/run-benchmark.mjs',
169+
'--worker',
170+
String(workerNumber),
171+
'--label',
172+
task.label,
173+
'--cacheDir',
174+
cacheDir,
175+
...passthroughArgs,
176+
],
177+
{
178+
label: `${workerLabel} ${task.label}`,
179+
},
180+
)
181+
} catch (error) {
182+
logSeries(`${workerLabel} pass ${task.runNumber} FAILED: ${error.message}`)
183+
}
180184

181185
completedTasks += 1
182186
const elapsedMs = Date.now() - taskStartedAt
@@ -201,9 +205,7 @@ async function main() {
201205
logSeries('Building Rollup production bundle')
202206
await runCommand('yarn', ['build'], { label: 'build' })
203207

204-
logSeries(
205-
`Starting scaling series with ${runCount} run(s) across ${workerCount} worker(s)`,
206-
)
208+
logSeries(`Starting scaling series with ${runCount} run(s) across ${workerCount} worker(s)`)
207209

208210
const tasks = buildRunTasks(runCount)
209211
await runTasksInParallel(tasks, workerCount)

docs/docs/examples/events.mdx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ export const TooltipAnchor = ({ children, id, ...rest }) => {
4141
)
4242
}
4343

44-
### Using `hover`
44+
### Hover (default)
4545

4646
:::info
4747

48-
This is the default event option, so it doesn't have to be manually set.
48+
Hover is the default behavior. No extra props are needed.
4949

5050
:::
5151

@@ -56,14 +56,13 @@ import { Tooltip } from 'react-tooltip';
5656
<Tooltip
5757
id="my-tooltip"
5858
content="Hello world!"
59-
events={['hover']}
6059
/>
6160
```
6261

6362
<TooltipAnchor data-tooltip-id="my-tooltip">◕‿‿◕</TooltipAnchor>
64-
<Tooltip id="my-tooltip" content="Hello world!" events={['hover']} />
63+
<Tooltip id="my-tooltip" content="Hello world!" />
6564

66-
### Using `click`
65+
### Click to open
6766

6867
:::info
6968

@@ -78,9 +77,9 @@ import { Tooltip } from 'react-tooltip';
7877
<Tooltip
7978
id="my-tooltip-click"
8079
content="Hello world!"
81-
events={['click']}
80+
openOnClick
8281
/>
8382
```
8483

8584
<TooltipAnchor data-tooltip-id="my-tooltip-click">◕‿‿◕</TooltipAnchor>
86-
<Tooltip id="my-tooltip-click" content="Hello world!" events={['click']} />
85+
<Tooltip id="my-tooltip-click" content="Hello world!" openOnClick />

docs/docs/examples/render.mdx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,11 @@ The `render` prop can be used to render the tooltip content dynamically based on
3939
The function signature is as follows:
4040

4141
```ts
42-
(render: { content: string | null; activeAnchor: HTMLElement | null }) => ChildrenType
42+
(render: { content: ReactNode | null; activeAnchor: HTMLElement | null }) => ReactNode
4343
```
4444

45-
- `content` is available for quick access to the `data-tooltip-content` attribute on the anchor element
45+
- `content` is the tooltip content (from the `content` prop or the `data-tooltip-content` attribute on the anchor element)
4646
- `activeAnchor` is a ref to the anchor element currently active (or `null` if no element is active)
47-
- `ChildrenType` is essentially the same as `React.ReactNode`
4847

4948
```jsx
5049
import { Tooltip } from 'react-tooltip';

docs/docs/examples/styling.mdx

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -479,35 +479,18 @@ Check out more details about the [base](#base-styles) and [core](#core-styles) s
479479

480480
:::danger
481481

482-
This has been deprecated. Use [`disableStyleInjection`](#disabling-reacttooltip-css) instead.
482+
Removed in v6. Use [`disableStyleInjection`](#disabling-reacttooltip-css) instead.
483483

484-
:::
485-
486-
You can prevent ReactTooltip from injecting styles into the page by using environment variables.
487-
488-
| name | type | required | default | values | description |
489-
| ----------------------------------- | --------- | -------- | ------- | -------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
490-
| `REACT_TOOLTIP_DISABLE_CORE_STYLES` | `boolean` | no | `false` | `true` `false` | Environment variable to disable **core** styles from being injected into the page by ReactTooltip.<br /><br /> We strongly recommend to keep the core styles being injected into the project unless you know what you are doing. |
491-
| `REACT_TOOLTIP_DISABLE_BASE_STYLES` | `boolean` | no | `false` | `true` `false` | Environment variable to disable **base** styles from being injected into the page by ReactTooltip.<br /><br /> Those styles are just visual styles like colors, padding, etc... And can be disabled if you want to write your tooltip styles. |
484+
The `REACT_TOOLTIP_DISABLE_CORE_STYLES` and `REACT_TOOLTIP_DISABLE_BASE_STYLES` environment variables are no longer supported.
492485

486+
:::
493487

494488
#### `removeStyle()` function
495489

496490
:::danger
497491

498-
This has been deprecated. Use [`disableStyleInjection`](#disabling-reacttooltip-css) instead.
499-
500-
:::
492+
Removed in v6. Use [`disableStyleInjection`](#disabling-reacttooltip-css) instead.
501493

502-
You can also use the `removeStyle()` function to remove injected styles from the page. It accepts the following parameters:
494+
The `removeStyle()` function is no longer exported.
503495

504-
| name | type | required | default | values | description |
505-
| ---- | ------ | -------- | ------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
506-
| type | string | no | `base` | `base` `core` | If `core` is defined, the core styles will be removed from the page, if nothing is defined, `base` styles will be removed as default value |
507-
508-
```jsx
509-
import { removeStyle } from 'react-tooltip'
510-
511-
removeStyle() // removes the injected base style of ReactTooltip
512-
removeStyle({ type: 'core' }) // removes the injected core style of ReactTooltip - this can affect the basic functionality of ReactTooltip
513-
```
496+
:::

0 commit comments

Comments
 (0)