|
| 1 | +program obrc_dcornelius; |
| 2 | +(* as: OBRC_DCornelius.dpr |
| 3 | + * by: David Cornelius |
| 4 | + * on: March, 2024 |
| 5 | + * in: Delphi 12 Athens |
| 6 | + * to: submit an entry in the One Billion Row Challenge |
| 7 | + * |
| 8 | + * Development/Testing was done on a 3.8 GHz Intel i7 desktop computer running Windows 11. |
| 9 | + * |
| 10 | + * NOTE: Build with 'Debug' configuration for messages, automatic timing, and a pause at the end. |
| 11 | + * Build with 'Release' configuration for the official submission. |
| 12 | + *) |
| 13 | + |
| 14 | +{$APPTYPE CONSOLE} |
| 15 | + |
| 16 | +{$R *.res} |
| 17 | + |
| 18 | +uses |
| 19 | + System.SysUtils, System.Classes, |
| 20 | + {$IFDEF DEBUG} |
| 21 | + System.Diagnostics, |
| 22 | + {$ENDIF } |
| 23 | + uChallengeWithDictionary in 'uChallengeWithDictionary.pas', |
| 24 | + uChallengeCommon in 'uChallengeCommon.pas', |
| 25 | + uChallengeWithStringList in 'uChallengeWithStringList.pas', |
| 26 | + udmChallengeWithFireDAC in 'udmChallengeWithFireDAC.pas' {dmChallengeWithFireDAC: TDataModule}; |
| 27 | + |
| 28 | +procedure DisplaySyntax; |
| 29 | +begin |
| 30 | + Writeln('SYNTAX: ' + ExtractFileName(ParamStr(0)) + ' <filename> <method>'); |
| 31 | + Writeln(' where <filename> is a text file with weather station data'); |
| 32 | + Writeln(' and <method> is the algorytm for summarizing the data:'); |
| 33 | + Writeln(' TSL = read in all data to a TStringList (lots of memory needed)'); |
| 34 | + Writeln(' DIC = build a Dictionary, then sort after built'); |
| 35 | + Writeln(' TBL = load a FireDAC in-memory table'); |
| 36 | + Writeln; |
| 37 | + Writeln('Press ENTER...'); |
| 38 | + Readln; |
| 39 | +end; |
| 40 | + |
| 41 | +begin |
| 42 | + try |
| 43 | + if ParamCount <> 2 then |
| 44 | + DisplaySyntax |
| 45 | + else begin |
| 46 | + {$IFDEF DEBUG} |
| 47 | + var StopWatch := TStopwatch.StartNew; |
| 48 | + {$ENDIF} |
| 49 | + ChallengeCommon := TChallengeCommon.Create(ParamStr(1)); |
| 50 | + try |
| 51 | + var Method := ParamStr(2); |
| 52 | + if SameText(Method, 'TSL') then |
| 53 | + ChallengeWithStringList |
| 54 | + else if SameText(Method, 'DIC') then |
| 55 | + ChallengeWithDictionary |
| 56 | + else if SameText(Method, 'TBL') then |
| 57 | + ChallengeWithFireDAC |
| 58 | + else |
| 59 | + raise EArgumentException.Create('Invalid method'); |
| 60 | + finally |
| 61 | + ChallengeCommon.Free; |
| 62 | + end; |
| 63 | + {$IFDEF DEBUG} |
| 64 | + StopWatch.Stop; |
| 65 | + Writeln('Elapsed Time (seconds/milliseconds): ', StopWatch.Elapsed.Seconds, ' / ', StopWatch.ElapsedMilliseconds); |
| 66 | + Readln; |
| 67 | + {$ENDIF} |
| 68 | + end; |
| 69 | + except |
| 70 | + on E: Exception do |
| 71 | + Writeln(E.ClassName, ': ', E.Message); |
| 72 | + end; |
| 73 | +end. |
0 commit comments