aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/docs/components/pages/TRPG-home/PackBenchmarks.tsx
blob: 0d3322cb09cdef2f69dabbeab60e6b971acd6e6f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import { useState } from "react"; 
import { FadeIn } from "../home-shared/FadeIn";
import { SectionHeader, SectionSubtext } from "../home-shared/Headings";
import { BenchmarksGraph } from "./PackBenchmarksGraph";
import { PackBenchmarksPicker } from "./PackBenchmarksPicker";
import { PackBenchmarkTabs } from "./PackBenchmarkTabs";

export type BenchmarkNumberOfModules = "1000" | "5000" | "10000" | "30000";
export type BenchmarkCategory =
  | "cold"
  | "from_cache"
  | "file_change"
  | "code_build"
  | "build_from_cache";
export interface BenchmarkData {
  HydroRoll: number;
  Shiki: number;
  OlivOS: number;
  SealDice: number;
}

export interface BenchmarkBar {
  label: string;
  key: keyof BenchmarkData;
  core?: true;
  swc?: true;
}

export const DEFAULT_BARS: BenchmarkBar[] = [
  {
    key: "HydroRoll",
    label: "HydroRoll水系",
    core: true,
  },
  {
    key: "Shiki",
    label: "溯洄Shiki",
  },
  {
    key: "OlivOS",
    label: "OlivOS青果",
    swc: true,
  },
  {
    key: "SealDice",
    label: "SealDice海豹",
  },
];
export const HMR_BARS: BenchmarkBar[] = [
  {
    key: "HydroRoll",
    label: "HydroRoll水系",
    core: true,
  },
  {
    key: "Shiki",
    label: "溯洄Shiki",
  },
  {
    key: "OlivOS",
    label: "OlivOS青果",
    swc: true,
  },
  {
    key: "SealDice",
    label: "SealDice海豹",
  },
];

export function PackBenchmarks() {
  const [numberOfModules, setNumberOfModules] =
    useState<BenchmarkNumberOfModules>("1000");
  const [category, setCategory] = useState<BenchmarkCategory>("cold");

  return (
    <FadeIn className="relative flex flex-col items-center justify-center w-full gap-10 py-16 font-sans md:py-24 lg:py-32">
      <div className="flex flex-col items-center gap-5 md:gap-6">
        <SectionHeader>速度不止于此</SectionHeader>
        <SectionSubtext>
          快速加载,模块化设计,fastapi、aiohttp、flask等高效率支持库,
          为核心提速。
        </SectionSubtext>
      </div>
      <div className="flex flex-col items-center w-full">
        <PackBenchmarkTabs onTabChange={setCategory} />
        <BenchmarksGraph
          category={category}
          numberOfModules={numberOfModules}
          bars={DEFAULT_BARS}
        />
      </div>
      <PackBenchmarksPicker
        setNumberOfModules={setNumberOfModules}
      ></PackBenchmarksPicker>
    </FadeIn>
  );
}