mirror of
https://github.com/discordeno/discordeno.git
synced 2026-09-17 08:47:22 +00:00
Remove benchmarks page & package (#4479)
* Remove benchmarks package and page * Remove benchmarks CI
This commit is contained in:
@@ -1,11 +0,0 @@
|
||||
---
|
||||
sidebar_position: 10
|
||||
---
|
||||
|
||||
# Benchmark
|
||||
|
||||
Benchmark runs on every commit pushed on the Discordeno's main branch
|
||||
|
||||
import Benchmark from '@site/src/components/Benchmark'
|
||||
|
||||
<Benchmark />
|
||||
@@ -25,11 +25,9 @@
|
||||
"@easyops-cn/docusaurus-search-local": "^0.52.1",
|
||||
"@mdx-js/react": "^3.1.0",
|
||||
"@xyflow/react": "^12.8.2",
|
||||
"chart.js": "^4.5.0",
|
||||
"clsx": "^2.1.1",
|
||||
"prism-react-renderer": "^2.4.1",
|
||||
"react": "^19.1.1",
|
||||
"react-chartjs-2": "^5.3.0",
|
||||
"react-dom": "^19.1.1",
|
||||
"styled-components": "^6.1.19"
|
||||
},
|
||||
|
||||
@@ -1,156 +0,0 @@
|
||||
import { CategoryScale, Chart as ChartJS, Legend, LinearScale, LineController, LineElement, PointElement, Title, Tooltip } from 'chart.js'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { Chart } from 'react-chartjs-2'
|
||||
|
||||
ChartJS.register(CategoryScale, LineController, LinearScale, PointElement, LineElement, Title, Tooltip, Legend)
|
||||
|
||||
const BenchmarkResultChart = ({
|
||||
name,
|
||||
dataset,
|
||||
}: {
|
||||
name: string
|
||||
dataset: Array<{
|
||||
bench: {
|
||||
name: string
|
||||
range: string | number
|
||||
unit: string
|
||||
value: string | number
|
||||
extra: string | number | undefined
|
||||
}
|
||||
commit: {
|
||||
author: {
|
||||
email: string
|
||||
name: string
|
||||
username: string
|
||||
}
|
||||
committer: {
|
||||
email: string
|
||||
name: string
|
||||
username: string
|
||||
}
|
||||
distinct: true
|
||||
id: string
|
||||
message: string
|
||||
timestamp: string
|
||||
tree_id: string
|
||||
url: string
|
||||
}
|
||||
date: number
|
||||
tool: string
|
||||
}>
|
||||
}) => {
|
||||
const data = {
|
||||
labels: dataset.map((d) => d.commit.id.slice(0, 7)),
|
||||
datasets: [
|
||||
{
|
||||
label: name,
|
||||
data: dataset.map((d) => d.bench.value),
|
||||
borderColor: '#ff3838',
|
||||
backgroundColor: '#ff383860', // Add alpha for #rrggbbaa
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
return (
|
||||
<Chart
|
||||
type="line"
|
||||
data={data}
|
||||
options={{
|
||||
responsive: true,
|
||||
scales: {
|
||||
x: {
|
||||
title: {
|
||||
display: true,
|
||||
text: 'commit',
|
||||
},
|
||||
},
|
||||
y: {
|
||||
title: {
|
||||
display: true,
|
||||
text: dataset.length > 0 ? dataset[0].bench.unit : '',
|
||||
},
|
||||
beginAtZero: true,
|
||||
},
|
||||
},
|
||||
plugins: {
|
||||
tooltip: {
|
||||
callbacks: {
|
||||
afterTitle: (items) => {
|
||||
const index = items[0].dataIndex
|
||||
const data = dataset[index]
|
||||
return '\n' + data.commit.message + '\n\n' + data.commit.timestamp + ' committed by @' + data.commit.author.username + '\n'
|
||||
},
|
||||
label: (item) => {
|
||||
let label = item.formattedValue
|
||||
const { range, unit } = dataset[item.datasetIndex].bench
|
||||
label += ` ${unit}`
|
||||
if (range) {
|
||||
label += ` (${range})`
|
||||
}
|
||||
return label
|
||||
},
|
||||
afterLabel: (item) => {
|
||||
const { extra } = dataset[item.datasetIndex].bench
|
||||
return extra ? `\n${extra}` : ''
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
onClick: (_mouseEvent, activeElems) => {
|
||||
if (activeElems.length === 0) {
|
||||
return
|
||||
}
|
||||
// XXX: Undocumented. How can we know the index?
|
||||
const index = activeElems[0].index
|
||||
const url = dataset[index].commit.url
|
||||
window.open(url, '_blank')
|
||||
},
|
||||
}}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
export default function BenchmarkResultCharts(): JSX.Element {
|
||||
const [data, setData] = useState<{ entries: { Benchmark: [] } }>()
|
||||
|
||||
useEffect(() => {
|
||||
if (!data) {
|
||||
void (async () => {
|
||||
setData(
|
||||
JSON.parse(
|
||||
(await (await fetch('https://raw.githubusercontent.com/discordeno/discordeno/benchies/benchmarksResult/data.js')).text()).slice(24),
|
||||
) as { entries: { Benchmark: [] } },
|
||||
)
|
||||
})()
|
||||
}
|
||||
}, [])
|
||||
|
||||
function collectBenchesPerTestCase(entries) {
|
||||
const dataMap = new Map()
|
||||
for (const entry of entries) {
|
||||
const { commit, date, tool, benches } = entry
|
||||
for (const bench of benches) {
|
||||
const result = { commit, date, tool, bench }
|
||||
const arr = dataMap.get(bench.name)
|
||||
if (arr === undefined) {
|
||||
dataMap.set(bench.name, [result])
|
||||
} else {
|
||||
arr.push(result)
|
||||
}
|
||||
}
|
||||
}
|
||||
return dataMap
|
||||
}
|
||||
|
||||
return (
|
||||
<div style={{ minHeight: '100vh' }}>
|
||||
{data ? (
|
||||
Array.from(collectBenchesPerTestCase(data.entries.Benchmark), ([key, value]) => ({ benchName: key, benches: value })).map((bench, index) => (
|
||||
<BenchmarkResultChart key={index} name={bench.benchName} dataset={bench.benches} />
|
||||
))
|
||||
) : (
|
||||
<></>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -7128,13 +7128,6 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@kurkle/color@npm:^0.3.0":
|
||||
version: 0.3.2
|
||||
resolution: "@kurkle/color@npm:0.3.2"
|
||||
checksum: 10c0/a9e8e3e35dcd59dec4dd4f0105919c05e24823a96347bcf152965c29e48d6290b66d5fb96c071875db752e10930724c48ce6d338fefbd65e0ce5082d5c78970e
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@leichtgewicht/ip-codec@npm:^2.0.1":
|
||||
version: 2.0.4
|
||||
resolution: "@leichtgewicht/ip-codec@npm:2.0.4"
|
||||
@@ -10276,15 +10269,6 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"chart.js@npm:^4.5.0":
|
||||
version: 4.5.0
|
||||
resolution: "chart.js@npm:4.5.0"
|
||||
dependencies:
|
||||
"@kurkle/color": "npm:^0.3.0"
|
||||
checksum: 10c0/f12c7f9a238ee7ce6d3f7111628e9daba86bb8ff8e54cfe63525fde6ded9003c72c4c8d2c7d5702539dc0aff7e682dfec058660ade8d03a970da002656d4ac91
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"cheerio-select@npm:^2.1.0":
|
||||
version: 2.1.0
|
||||
resolution: "cheerio-select@npm:2.1.0"
|
||||
@@ -17628,16 +17612,6 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"react-chartjs-2@npm:^5.3.0":
|
||||
version: 5.3.0
|
||||
resolution: "react-chartjs-2@npm:5.3.0"
|
||||
peerDependencies:
|
||||
chart.js: ^4.1.1
|
||||
react: ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0
|
||||
checksum: 10c0/4415d40217c084a49f9a936fbd30f67e0e705148e6f8359bec65601033d1076f31085c45793839fc29ec833e6c427b0bf9861a0c54c432c08d35bc9590ffa41a
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"react-dev-utils@npm:^12.0.1":
|
||||
version: 12.0.1
|
||||
resolution: "react-dev-utils@npm:12.0.1"
|
||||
@@ -20197,11 +20171,9 @@ __metadata:
|
||||
"@mdx-js/react": "npm:^3.1.0"
|
||||
"@types/react": "npm:^19.1.10"
|
||||
"@xyflow/react": "npm:^12.8.2"
|
||||
chart.js: "npm:^4.5.0"
|
||||
clsx: "npm:^2.1.1"
|
||||
prism-react-renderer: "npm:^2.4.1"
|
||||
react: "npm:^19.1.1"
|
||||
react-chartjs-2: "npm:^5.3.0"
|
||||
react-dom: "npm:^19.1.1"
|
||||
styled-components: "npm:^6.1.19"
|
||||
typescript: "npm:5.9.2"
|
||||
|
||||
Reference in New Issue
Block a user