whitphx HF Staff commited on
Commit
e115965
·
1 Parent(s): 9a01936
Files changed (2) hide show
  1. bench/src/core/args.ts +19 -2
  2. bench/src/web/cli.ts +16 -2
bench/src/core/args.ts CHANGED
@@ -13,8 +13,25 @@ export function getArg(name: string, def?: string): string | undefined {
13
  }
14
 
15
  export function parseArgs() {
16
- const modelId = process.argv[2] || "Xenova/distilbert-base-uncased";
17
- const task = process.argv[3] || "feature-extraction";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  const mode = (getArg("mode", "warm") as "warm" | "cold");
19
  const repeats = Math.max(1, parseInt(getArg("repeats", "3") || "3", 10));
20
  const dtype = getArg("dtype"); // optional: fp32, fp16, q8, q4, etc.
 
13
  }
14
 
15
  export function parseArgs() {
16
+ const modelId = process.argv[2];
17
+ const task = process.argv[3];
18
+
19
+ if (!modelId) {
20
+ throw new Error(
21
+ "modelId is required\n" +
22
+ "Usage: tsx src/node/index.ts <modelId> <task> [options]\n" +
23
+ "Example: tsx src/node/index.ts Xenova/distilbert-base-uncased feature-extraction"
24
+ );
25
+ }
26
+
27
+ if (!task) {
28
+ throw new Error(
29
+ "task is required\n" +
30
+ "Usage: tsx src/node/index.ts <modelId> <task> [options]\n" +
31
+ "Example: tsx src/node/index.ts Xenova/distilbert-base-uncased feature-extraction"
32
+ );
33
+ }
34
+
35
  const mode = (getArg("mode", "warm") as "warm" | "cold");
36
  const repeats = Math.max(1, parseInt(getArg("repeats", "3") || "3", 10));
37
  const dtype = getArg("dtype"); // optional: fp32, fp16, q8, q4, etc.
bench/src/web/cli.ts CHANGED
@@ -4,8 +4,22 @@ import { getArg } from "../core/args.js";
4
 
5
  // CLI for running browser benchmarks headlessly via Playwright
6
 
7
- const modelId = process.argv[2] || "Xenova/distilbert-base-uncased";
8
- const task = process.argv[3] || "feature-extraction";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
 
10
  const mode = getArg("mode", "warm") as "warm" | "cold";
11
  const repeats = Math.max(1, parseInt(getArg("repeats", "3") || "3", 10));
 
4
 
5
  // CLI for running browser benchmarks headlessly via Playwright
6
 
7
+ const modelId = process.argv[2];
8
+ const task = process.argv[3];
9
+
10
+ if (!modelId) {
11
+ console.error("Error: modelId is required");
12
+ console.error("Usage: tsx src/web/cli.ts <modelId> <task> [options]");
13
+ console.error("Example: tsx src/web/cli.ts Xenova/distilbert-base-uncased feature-extraction");
14
+ process.exit(1);
15
+ }
16
+
17
+ if (!task) {
18
+ console.error("Error: task is required");
19
+ console.error("Usage: tsx src/web/cli.ts <modelId> <task> [options]");
20
+ console.error("Example: tsx src/web/cli.ts Xenova/distilbert-base-uncased feature-extraction");
21
+ process.exit(1);
22
+ }
23
 
24
  const mode = getArg("mode", "warm") as "warm" | "cold";
25
  const repeats = Math.max(1, parseInt(getArg("repeats", "3") || "3", 10));