mORMot and Open Source friends
Check-in [e758ebb6c0]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
SHA1 Hash:e758ebb6c006e14d353d0411a4768abfeae0d853
Date: 2015-02-01 13:06:11
User: ab
Comment:{797} included QDAC3 in "25 - JSON performance" sample
Tags And Properties
Context
2015-02-01
17:23
[8928003809] {798} ensure THttpServerRequest.AuthenticatedUser will be set before call to the Request() method, when HTTP API 2.0 authentication has been successfull (user: ab, tags: trunk)
13:06
[e758ebb6c0] {797} included QDAC3 in "25 - JSON performance" sample (user: ab, tags: trunk)
08:48
[cd18df561f] {796} updated SQLite3 engine to latest version 3.8.8.2 (user: ab, tags: trunk)
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to SQLite3/Samples/25 - JSON performance/JSONPerfTestCases.pas.

7
8
9
10
11
12
13


14
15
16
17
18
19
20
..
55
56
57
58
59
60
61



62
63
64
65
66
67
68
...
143
144
145
146
147
148
149









150
151
152
153
154
155
156
...
180
181
182
183
184
185
186



187
188
189
190
191
192
193
...
209
210
211
212
213
214
215



216
217
218
219
220
221
222
...
231
232
233
234
235
236
237
238



239
240
241
242
243
244
245
...
262
263
264
265
266
267
268



269
270
271
272
273
274
275
...
725
726
727
728
729
730
731














































732
733
734
735
736
737
738
....
1109
1110
1111
1112
1113
1114
1115














1116
1117
1118
1119
1120
1121
1122
....
1209
1210
1211
1212
1213
1214
1215














1216
1217
1218
1219
1220
1221
1222
....
1608
1609
1610
1611
1612
1613
1614






















1615
1616
1617
1618
1619
1620
1621

// download from https://code.google.com/p/superobject
{.$define USESUPEROBJECT}

{$ifdef ISDELPHI2010}
  // download from https://code.google.com/p/x-superobject
  {.$define USEXSUPEROBJECT}


{$endif}

{$ifdef USEXSUPEROBJECT}
  {$undef USESUPEROBJECT} // both libraries are exclusive! :(
{$endif}

{$ifdef CPU64}
................................................................................
  {$endif}
  {$ifdef USEDBXJSON}
  {$ifdef ISDELPHIXE6}
  JSON,
  {$else}
  DBXJSON,
  {$endif}



  {$endif}
  SynCrtSock,
  SynZip,
  {$ifdef TESTBSON}
  SynMongoDB,
  {$endif}
  mORMot,
................................................................................
  TTestdwsJSON = class(TSynTestCase)
  published
    procedure Read;
    procedure Access;
    procedure Write;
  end;
  {$endif}










  {$ifdef USEDBXJSON}
  TTestDBXJSON = class(TSynTestCase)
  published
    procedure Read;
    procedure Access;
    procedure Write;
................................................................................
    {$endif}
    {$ifdef USEDWSJSON}
    procedure dwsJSONRead;
    {$endif}
    {$ifdef USEDBXJSON}
    procedure DBXJSONRead;
    {$endif}



  end;

  TTestTableContent = class(TTestBigContentRead)
  protected
  published
    procedure DownloadFilesIfNecessary; override;
    procedure SynopseParse;
................................................................................
    {$endif}
    {$ifdef USEDWSJSON}
    procedure dwsJSON;
    {$endif}
    {$ifdef USEDBXJSON}
    procedure DBXJSON;
    {$endif}



  end;

  TTestHugeContent = class(TTestBigContentRead)
  protected
    procedure GeoJSONCoordWriter(const aWriter: TTextWriter; const aValue);
    function GeoJSONCoordReader(P: PUTF8Char; var aValue; out aValid: Boolean): PUTF8Char;
  published
................................................................................
    {$ifdef USESUPEROBJECT}
    procedure SuperObjectRead;
    {$endif}
    {$ifdef USEDWSJSON}
    procedure dwsJSONRead;
    {$endif}
    {$ifdef USEDBXJSON}
    procedure DBXJSONRead; 



    {$endif}
  end;


implementation


................................................................................
    TTestXSuperObjectProperties
  {$endif}
  {$ifdef USEDWSJSON},
    TTestdwsJSON
  {$endif}
  {$ifdef USEDBXJSON},
    TTestDBXJSON



  {$endif}
  ]);
end;

procedure TTestJSONBenchmarking.BigContent;
begin
  AddCase([TTestDepthContent,TTestTableContent]);
................................................................................
    check(Hash32(json)=$293BAAA1);
  end;
  obj.Free;
end;

{$endif USEDWSJSON}

















































{$ifdef USEDBXJSON}

{ TTestDBXJSON }

{$ifndef ISDELPHIXE6}
................................................................................
  check(obj['type'].AsString='FeatureCollection');
  fRunConsoleOccurenceNumber := obj['features'].ElementCount;
  check(fRunConsoleOccurenceNumber=206560);
  fRunConsoleMemoryUsed := MemoryUsed-fMemoryAtStart;
  obj.Free;
end;
{$endif}















{$ifdef USEDBXJSON}
procedure TTestHugeContent.DBXJSONRead;
var json: UTF8String;
    obj: TJSONObject;
begin
  {$ifndef CPU64}
................................................................................
begin
  obj := TdwsJSONValue.ParseFile(fFileName);
  check(obj['a']['obj']['key'].AsString='wrong value');
  fRunConsoleMemoryUsed := MemoryUsed-fMemoryAtStart;
  obj.Free;
end;
{$endif}















{$ifdef USEDBXJSON}
procedure TTestDepthContent.DBXJSONRead;
var json: UTF8String;
    obj: TJSONObject;
begin
  json := StringFromFile(fFileName);
................................................................................
    with obj.Elements[i] do begin
      Check(Values['FirstName'].AsString<>'');
      Check(Values['LastName'].AsString<>'');
      Check(Values['YearOfBirth'].AsInteger<10000);
      Check((Values['YearOfDeath'].AsInteger>1400)and(Values['YearOfDeath'].AsInteger<2000));
      Check((Values['RowID'].AsInteger>11011) or (Values['Data'].AsString<>''));
    end;






















  check(fRunConsoleOccurenceNumber>8000);
  fRunConsoleMemoryUsed := MemoryUsed-fMemoryAtStart;
  obj.Free;
end;
{$endif}

{$ifdef USEDBXJSON}







>
>







 







>
>
>







 







>
>
>
>
>
>
>
>
>







 







>
>
>







 







>
>
>







 







|
>
>
>







 







>
>
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
..
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
...
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
...
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
...
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
...
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
...
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
...
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
....
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
....
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
....
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743

// download from https://code.google.com/p/superobject
{.$define USESUPEROBJECT}

{$ifdef ISDELPHI2010}
  // download from https://code.google.com/p/x-superobject
  {.$define USEXSUPEROBJECT}
  // download from http://sourceforge.net/projects/qdac3
  {.$define USEQDAC}
{$endif}

{$ifdef USEXSUPEROBJECT}
  {$undef USESUPEROBJECT} // both libraries are exclusive! :(
{$endif}

{$ifdef CPU64}
................................................................................
  {$endif}
  {$ifdef USEDBXJSON}
  {$ifdef ISDELPHIXE6}
  JSON,
  {$else}
  DBXJSON,
  {$endif}
  {$endif}
  {$ifdef USEQDAC}
  qjson,
  {$endif}
  SynCrtSock,
  SynZip,
  {$ifdef TESTBSON}
  SynMongoDB,
  {$endif}
  mORMot,
................................................................................
  TTestdwsJSON = class(TSynTestCase)
  published
    procedure Read;
    procedure Access;
    procedure Write;
  end;
  {$endif}

  {$ifdef USEQDAC}
  TTestQDAC = class(TSynTestCase)
  published
    procedure Read;
    procedure Access;
    procedure Write;
  end;
  {$endif}

  {$ifdef USEDBXJSON}
  TTestDBXJSON = class(TSynTestCase)
  published
    procedure Read;
    procedure Access;
    procedure Write;
................................................................................
    {$endif}
    {$ifdef USEDWSJSON}
    procedure dwsJSONRead;
    {$endif}
    {$ifdef USEDBXJSON}
    procedure DBXJSONRead;
    {$endif}
    {$ifdef USEQDACFIXED} // QDAC is not able to parse "" as key :(
    procedure QDACRead;
    {$endif}
  end;

  TTestTableContent = class(TTestBigContentRead)
  protected
  published
    procedure DownloadFilesIfNecessary; override;
    procedure SynopseParse;
................................................................................
    {$endif}
    {$ifdef USEDWSJSON}
    procedure dwsJSON;
    {$endif}
    {$ifdef USEDBXJSON}
    procedure DBXJSON;
    {$endif}
    {$ifdef USEQDAC}
    procedure QDAC;
    {$endif}
  end;

  TTestHugeContent = class(TTestBigContentRead)
  protected
    procedure GeoJSONCoordWriter(const aWriter: TTextWriter; const aValue);
    function GeoJSONCoordReader(P: PUTF8Char; var aValue; out aValid: Boolean): PUTF8Char;
  published
................................................................................
    {$ifdef USESUPEROBJECT}
    procedure SuperObjectRead;
    {$endif}
    {$ifdef USEDWSJSON}
    procedure dwsJSONRead;
    {$endif}
    {$ifdef USEDBXJSON}
    procedure DBXJSONRead;
    {$endif}
    {$ifdef USEQDAC}
    procedure QDACRead;
    {$endif}
  end;


implementation


................................................................................
    TTestXSuperObjectProperties
  {$endif}
  {$ifdef USEDWSJSON},
    TTestdwsJSON
  {$endif}
  {$ifdef USEDBXJSON},
    TTestDBXJSON
  {$endif}
  {$ifdef USEQDAC},
    TTestQDAC
  {$endif}
  ]);
end;

procedure TTestJSONBenchmarking.BigContent;
begin
  AddCase([TTestDepthContent,TTestTableContent]);
................................................................................
    check(Hash32(json)=$293BAAA1);
  end;
  obj.Free;
end;

{$endif USEDWSJSON}

{$ifdef USEQDAC}

{ TTestQDAC }

procedure TTestQDAC.Read;
var obj: TQJson;
    i: integer;
begin
  for i := 1 to SAMPLE_JSON_1_COUNT do begin
    obj := TQJson.Create;
    obj.Parse(SAMPLE_JSON_1);
    check(obj.ItemByPath('glossary.title').AsString='example glossary');
    obj.Free;
  end;
end;

procedure TTestQDAC.Access;
var obj: TQJson;
    i: integer;
begin
  obj := TQJson.Create;
  obj.Parse(SAMPLE_JSON_1);
  Owner.TestTimer.Start;
  for i := 1 to SAMPLE_JSON_1_COUNT do begin
    check(obj.ItemByPath('glossary.title').AsString='example glossary');
    check(obj.ItemByPath('glossary.GlossDiv.GlossList.GlossEntry.GlossDef.GlossSeeAlso')[0].AsString='GML');
  end;
  obj.Free;
end;

procedure TTestQDAC.Write;
var obj: TQJson;
    i: integer;
    json: RawUTF8;
begin
  obj := TQJson.Create;
  obj.Parse(SAMPLE_JSON_1);
  Owner.TestTimer.Start;
  for i := 1 to SAMPLE_JSON_1_COUNT do begin
    StringToUTF8(obj.Encode(False),json); // (false)=no format
    check(Hash32(json)=$293BAAA1);
  end;
  obj.Free;
end;

{$endif USEQDAC}


{$ifdef USEDBXJSON}

{ TTestDBXJSON }

{$ifndef ISDELPHIXE6}
................................................................................
  check(obj['type'].AsString='FeatureCollection');
  fRunConsoleOccurenceNumber := obj['features'].ElementCount;
  check(fRunConsoleOccurenceNumber=206560);
  fRunConsoleMemoryUsed := MemoryUsed-fMemoryAtStart;
  obj.Free;
end;
{$endif}

{$ifdef USEQDAC}
procedure TTestHugeContent.QDACRead;
var obj: TQJson;
begin
  obj := TQJson.Create;
  obj.LoadFromFile(fFileName);
  check(obj.ItemByName('type').AsString='FeatureCollection');
  fRunConsoleOccurenceNumber := obj.ItemByName('features').Count;
  check(fRunConsoleOccurenceNumber=206560);
  fRunConsoleMemoryUsed := MemoryUsed-fMemoryAtStart;
  obj.Free;
end;
{$endif}

{$ifdef USEDBXJSON}
procedure TTestHugeContent.DBXJSONRead;
var json: UTF8String;
    obj: TJSONObject;
begin
  {$ifndef CPU64}
................................................................................
begin
  obj := TdwsJSONValue.ParseFile(fFileName);
  check(obj['a']['obj']['key'].AsString='wrong value');
  fRunConsoleMemoryUsed := MemoryUsed-fMemoryAtStart;
  obj.Free;
end;
{$endif}

{$ifdef USEQDACFIXED}
procedure TTestDepthContent.QDACRead;
var obj: TQJson;
begin
  fRunConsole := fRunConsole+'QDAC is not able to parse "" as key';
  exit;
  obj := TQJson.Create;
  obj.LoadFromFile(fFileName);
  check(obj.ItemByPath('a.obj.key').AsString='wrong value');
  fRunConsoleMemoryUsed := MemoryUsed-fMemoryAtStart;
  obj.Free;
end;
{$endif}

{$ifdef USEDBXJSON}
procedure TTestDepthContent.DBXJSONRead;
var json: UTF8String;
    obj: TJSONObject;
begin
  json := StringFromFile(fFileName);
................................................................................
    with obj.Elements[i] do begin
      Check(Values['FirstName'].AsString<>'');
      Check(Values['LastName'].AsString<>'');
      Check(Values['YearOfBirth'].AsInteger<10000);
      Check((Values['YearOfDeath'].AsInteger>1400)and(Values['YearOfDeath'].AsInteger<2000));
      Check((Values['RowID'].AsInteger>11011) or (Values['Data'].AsString<>''));
    end;
  check(fRunConsoleOccurenceNumber>8000);
  fRunConsoleMemoryUsed := MemoryUsed-fMemoryAtStart;
  obj.Free;
end;
{$endif}

{$ifdef USEQDAC}
procedure TTestTableContent.QDAC;
var obj: TQJson;
    i: integer;
begin
  obj := TQJson.Create;
  obj.LoadFromFile(fFileName);
  fRunConsoleOccurenceNumber := obj.Count;
  for i := 0 to fRunConsoleOccurenceNumber-1 do
    with obj.Items[i] do begin
      Check(ItemByName('FirstName').AsString<>'');
      Check(ItemByName('LastName').AsString<>'');
      Check(ItemByName('YearOfBirth').AsInteger<10000);
      Check((ItemByName('YearOfDeath').AsInteger>1400)and(ItemByName('YearOfDeath').AsInteger<2000));
      Check((ItemByName('RowID').AsInteger>11011) or (ItemByName('Data').AsString<>''));
    end;
  check(fRunConsoleOccurenceNumber>8000);
  fRunConsoleMemoryUsed := MemoryUsed-fMemoryAtStart;
  obj.Free;
end;
{$endif}

{$ifdef USEDBXJSON}

Changes to SynopseCommit.inc.

1
'1.18.796'
|
1
'1.18.797'