MCPcopy Create free account
hub / github.com/antirez/ds4 / parse_options

Function parse_options

ds4_bench.c:168–329  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

166 }
167 if (fseek(fp, 0, SEEK_END) != 0) {
168 fprintf(stderr, "ds4-bench: failed to seek %s\n", path);
169 fclose(fp);
170 exit(1);
171 }
172 long n = ftell(fp);
173 if (n < 0) {
174 fprintf(stderr, "ds4-bench: failed to tell %s\n", path);
175 fclose(fp);
176 exit(1);
177 }
178 if (fseek(fp, 0, SEEK_SET) != 0) {
179 fprintf(stderr, "ds4-bench: failed to rewind %s\n", path);
180 fclose(fp);
181 exit(1);
182 }
183 char *buf = malloc((size_t)n + 1);
184 if (!buf) {
185 fprintf(stderr, "ds4-bench: out of memory reading %s\n", path);
186 fclose(fp);
187 exit(1);
188 }
189 if (fread(buf, 1, (size_t)n, fp) != (size_t)n) {
190 fprintf(stderr, "ds4-bench: failed to read %s\n", path);
191 free(buf);
192 fclose(fp);
193 exit(1);
194 }
195 fclose(fp);
196 buf[n] = '\0';
197 return buf;
198}
199
200static bench_config parse_options(int argc, char **argv) {
201 bench_config c = {
202 .model_path = "ds4flash.gguf",
203 .system = "You are a helpful assistant.",
204 .backend = default_backend(),
205 .ctx_start = 2048,
206 .ctx_max = 32768,
207 .step_incr = 2048,
208 .gen_tokens = 128,
209 .step_mul = 1.0,
210 };
211
212 for (int i = 1; i < argc; i++) {
213 const char *arg = argv[i];
214 if (!strcmp(arg, "-h") || !strcmp(arg, "--help")) {
215 const char *topic = (i + 1 < argc && argv[i + 1][0] != '-') ?
216 argv[i + 1] : NULL;
217 usage(stdout, topic);
218 exit(0);
219 }
220 char dist_parse_err[256] = {0};
221 ds4_dist_cli_parse_result dist_parse =
222 ds4_dist_parse_cli_arg(arg,
223 &i,
224 argc,
225 argv,

Callers 1

mainFunction · 0.70

Calls 11

ds4_dist_parse_cli_argFunction · 0.85
parse_double_argFunction · 0.85
parse_nonnegative_intFunction · 0.85
ds4_parse_gib_argFunction · 0.85
default_backendFunction · 0.70
usageFunction · 0.70
need_argFunction · 0.70
parse_intFunction · 0.70
parse_backendFunction · 0.70

Tested by

no test coverage detected