|
31 | 31 | var |
32 | 32 | JumperCount: UPS; |
33 | 33 | PartSize: UPS; |
| 34 | + ProcessorCount: U8; |
34 | 35 |
|
35 | 36 | type |
36 | 37 | THash = U32; |
@@ -240,11 +241,6 @@ TStationSummary = record |
240 | 241 |
|
241 | 242 | procedure Process(out AStations: TStationResultArray); overload; |
242 | 243 |
|
243 | | - function ProcessorCount: U8; |
244 | | - begin |
245 | | - Result := LogicalProcessorCount; |
246 | | - end; |
247 | | - |
248 | 244 | procedure Initialize(out AContext: TContext); |
249 | 245 | var |
250 | 246 | I: Ind; |
@@ -368,27 +364,55 @@ TStationSummary = record |
368 | 364 | WriteLn(ToStr(RST)); |
369 | 365 | end; |
370 | 366 |
|
371 | | -var |
372 | | - I: Ind; |
373 | | - N: Str; |
374 | | - V: I64; |
375 | | -begin |
376 | | - if Length(Parameters) = 0 then |
377 | | - Exit; |
| 367 | + function HandleParameters(out AFilePath: TFilePath): Bool; |
| 368 | + var |
| 369 | + I: Ind; |
| 370 | + N: Str; |
| 371 | + V: I64; |
| 372 | + begin |
| 373 | + Result := False; |
| 374 | + if Length(Parameters) = 0 then |
| 375 | + begin |
| 376 | + WriteLn; |
| 377 | + WriteLn('1BRC'); |
| 378 | + WriteLn('----'); |
| 379 | + WriteLn('Made by O'); |
| 380 | + WriteLn; |
| 381 | + WriteLn('Usage:'); |
| 382 | + WriteLn('./ocoddo ./input.txt [Options]'); |
| 383 | + WriteLn; |
| 384 | + WriteLn('Options:'); |
| 385 | + WriteLn('--jumper-count=[Value]. Use 128, 192, 256, etc'); |
| 386 | + WriteLn('--part-size=[Value]. Use 128, 192, 256, etc'); |
| 387 | + WriteLn('--processor-count=[Value]. Use 1 or more'); |
| 388 | + WriteLn; |
| 389 | + Exit; |
| 390 | + end; |
378 | 391 |
|
379 | | - JumperCount := 256 * 1024; |
380 | | - PartSize := 192 * 1024 - ReadMargin; |
| 392 | + ProcessorCount := LogicalProcessorCount; |
| 393 | + JumperCount := 256 * 1024; |
| 394 | + PartSize := 192 * 1024 - ReadMargin; |
381 | 395 |
|
382 | | - for I := 1 to High(Parameters) do |
383 | | - begin |
384 | | - N := Name(Parameters[I]); |
385 | | - ToI64(Value(Parameters[I]), V); |
| 396 | + for I := 1 to High(Parameters) do |
| 397 | + begin |
| 398 | + N := Name(Parameters[I]); |
| 399 | + ToI64(Value(Parameters[I]), V); |
| 400 | + |
| 401 | + if N = 'jumper-count' then |
| 402 | + JumperCount := V * 1024 |
| 403 | + else if N = 'part-size' then |
| 404 | + PartSize := (V * 1024) - ReadMargin |
| 405 | + else if N = 'processor-count' then |
| 406 | + ProcessorCount := V; |
| 407 | + end; |
386 | 408 |
|
387 | | - if N = 'jumper-count' then |
388 | | - JumperCount := V * 1024 |
389 | | - else if N = 'part-size' then |
390 | | - PartSize := (V * 1024) - ReadMargin; |
| 409 | + AFilePath := Fix(Value(Parameters[0])); |
| 410 | + Result := True; |
391 | 411 | end; |
392 | 412 |
|
393 | | - Run(&File(Fix(Value(Parameters[0])))); |
| 413 | +var |
| 414 | + FN: TFilePath; |
| 415 | +begin |
| 416 | + if HandleParameters(FN) then |
| 417 | + Run(&File(FN)); |
394 | 418 | end. |
0 commit comments