Skip to content

Commit 003eb72

Browse files
committed
Add total performance, adjust theme
1 parent bf8d6e7 commit 003eb72

File tree

6 files changed

+28
-2
lines changed

6 files changed

+28
-2
lines changed

docs/src/App.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ export default function App() {
4646
lex: parsed.lex,
4747
layout: parsed.layout,
4848
parse: parsed.parse,
49+
total: parsed.lex + parsed.layout + parsed.parse,
4950
});
5051

5152
// Run type checker if in that mode
@@ -61,6 +62,7 @@ export default function App() {
6162
resolve: checked.timing.resolve,
6263
lower: checked.timing.lower,
6364
check: checked.timing.check,
65+
total: checked.timing.total,
6466
});
6567
}
6668
} catch (err) {

docs/src/components/PerformanceBar.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ export function PerformanceBar({ timing }: Props) {
3131
<span className="font-mono text-fg-muted">{formatMs(metric.value!)}</span>
3232
</div>
3333
))}
34+
<div className="flex items-center gap-1.5 border-l border-bg-lighter pl-4">
35+
<span className="font-medium">Total:</span>
36+
<span className="font-mono text-fg-muted">{formatMs(timing.total)}</span>
37+
</div>
3438
</div>
3539
);
3640
}

docs/src/lib/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export interface CheckTiming {
3030
resolve: number;
3131
lower: number;
3232
check: number;
33+
total: number;
3334
}
3435

3536
export interface CheckResult {
@@ -49,6 +50,7 @@ export interface Timing {
4950
resolve?: number;
5051
lower?: number;
5152
check?: number;
53+
total: number;
5254
}
5355

5456
export interface Lib {

docs/src/themes/catppuccin.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,10 @@ function createTheme(palette: Palette, base: "vs" | "vs-dark"): monaco.editor.IS
107107
colors: {
108108
"editor.background": palette.base,
109109
"editor.foreground": palette.text,
110-
"editor.lineHighlightBackground": palette.surface0,
111-
"editor.selectionBackground": palette.surface2,
110+
"editor.lineHighlightBackground": palette.text + "12",
111+
"editor.selectionBackground": palette.overlay2 + (base === "vs" ? "4D" : "40"),
112+
"editor.wordHighlightBackground": palette.overlay2 + "33",
113+
"editor.wordHighlightStrongBackground": palette.blue + (base === "vs" ? "26" : "33"),
112114
"editorCursor.foreground": palette.rosewater,
113115
"editorLineNumber.foreground": palette.overlay0,
114116
"editorLineNumber.activeForeground": palette.lavender,

docs/src/wasm/src/lib.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ pub struct CheckTiming {
8787
resolve: f64,
8888
lower: f64,
8989
check: f64,
90+
total: f64,
9091
}
9192

9293
#[derive(Serialize)]
@@ -103,6 +104,8 @@ pub fn check(source: &str) -> JsValue {
103104
let performance = get_performance();
104105

105106
let result = ENGINE.with_borrow_mut(|engine| {
107+
let total_start = performance.now();
108+
106109
// Parse
107110
let start = performance.now();
108111
let lexed = lexing::lex(source);
@@ -145,6 +148,7 @@ pub fn check(source: &str) -> JsValue {
145148
resolve: 0.0,
146149
lower: 0.0,
147150
check: 0.0,
151+
total: performance.now() - total_start,
148152
},
149153
};
150154
}
@@ -171,6 +175,7 @@ pub fn check(source: &str) -> JsValue {
171175
resolve: 0.0,
172176
lower: 0.0,
173177
check: 0.0,
178+
total: performance.now() - total_start,
174179
},
175180
};
176181
}
@@ -196,6 +201,7 @@ pub fn check(source: &str) -> JsValue {
196201
resolve: resolve_time,
197202
lower: 0.0,
198203
check: 0.0,
204+
total: performance.now() - total_start,
199205
},
200206
};
201207
}
@@ -223,6 +229,7 @@ pub fn check(source: &str) -> JsValue {
223229
resolve: resolve_time,
224230
lower: lower_time,
225231
check: 0.0,
232+
total: performance.now() - total_start,
226233
},
227234
};
228235
}
@@ -283,6 +290,8 @@ pub fn check(source: &str) -> JsValue {
283290
});
284291
}
285292

293+
let total_time = performance.now() - total_start;
294+
286295
CheckResult {
287296
terms,
288297
types,
@@ -297,6 +306,7 @@ pub fn check(source: &str) -> JsValue {
297306
resolve: resolve_time,
298307
lower: lower_time,
299308
check: check_time,
309+
total: total_time,
300310
},
301311
}
302312
});

docs/vite.config.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ import tailwindcss from "@tailwindcss/vite";
55
export default defineConfig({
66
base: "/purescript-analyzer/",
77
plugins: [react(), tailwindcss()],
8+
server: {
9+
headers: {
10+
"Cross-Origin-Opener-Policy": "same-origin",
11+
"Cross-Origin-Embedder-Policy": "require-corp",
12+
},
13+
},
814
build: {
915
outDir: "build",
1016
target: "esnext",

0 commit comments

Comments
 (0)