Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Comment: | {906} introducing JsonDataObjects library in our JSON performance benchmark |
---|---|
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
efcb1f0b854dd2b7ec54aac38184e37d |
User & Date: | ab 2015-02-16 11:16:39 |
2015-02-16
| ||
12:20 | {907} added TSQLTable.FieldAsFloat() overloaded methods check-in: 13c49a84b0 user: ab tags: trunk | |
11:16 | {906} introducing JsonDataObjects library in our JSON performance benchmark check-in: efcb1f0b85 user: ab tags: trunk | |
11:15 | {905} added JSONReformatToFile() JSONBufferReformatToFile() functions and use tab indentation instead of two spaces (also for JSONReformat/JSONBufferReformat/TTextWriter.AddJSONReformat) check-in: 2ef1896cd3 user: ab tags: trunk | |
Changes to SQLite3/Samples/25 - JSON performance/JSONPerfTestCases.pas.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 .. 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 .. 51 52 53 54 55 56 57 58 59 60 61 62 63 64 ... 148 149 150 151 152 153 154 155 156 157 158 159 160 161 ... 194 195 196 197 198 199 200 201 202 203 204 205 206 207 ... 226 227 228 229 230 231 232 233 234 235 236 237 238 239 ... 253 254 255 256 257 258 259 260 261 262 263 264 265 266 ... 289 290 291 292 293 294 295 296 297 298 299 300 301 302 ... 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 ... 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 ... 798 799 800 801 802 803 804 805 806 807 808 809 810 811 ... 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 ... 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 .... 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 .... 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 .... 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 .... 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 .... 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 |
{$I Synopse.inc} // 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} // SuperObject just explodes under Win64 :( {$undef USEXSUPEROBJECT} // XSuperObject just explodes under Win64 :( {$endif} {$ifdef ISDELPHI2010} // download from https://code.google.com/p/dwscript {.$define USEDWSJSON} {$endif} {$ifdef ISDELPHIXE} // Delphi 2010 DBXJSON is just buggy and not workable {$define USEDBXJSON} {$endif} {$define TESTBSON} uses {$I SynDprUses.inc} // link FastMM4 for older versions of Delphi Windows, ................................................................................ {$endif} {$ifdef USESUPEROBJECT} superobject, {$endif} {$ifdef USEDWSJSON} dwsJSON, {$endif} {$ifdef USEDBXJSON} {$ifdef ISDELPHIXE6} JSON, {$else} DBXJSON, {$endif} {$endif} ................................................................................ TTestdwsJSON = class(TSynTestCase) published procedure Read; procedure Access; procedure Write; end; {$endif} {$ifdef USEQDAC} TTestQDAC = 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 ................................................................................ {$endif} {$ifdef USEDWSJSON} procedure dwsJSON; {$endif} {$ifdef USEDBXJSON} procedure DBXJSON; {$endif} {$ifdef USEQDAC} procedure QDAC; {$endif} end; TTestHugeContent = class(TTestBigContentRead) protected ................................................................................ {$endif} {$ifdef USEDWSJSON} procedure dwsJSONRead; {$endif} {$ifdef USEDBXJSON} procedure DBXJSONRead; {$endif} {$ifdef USEQDAC} procedure QDACRead; {$endif} end; implementation ................................................................................ {$endif} {$ifdef USEDBXJSON}, TTestDBXJSON {$endif} {$ifdef USEQDAC}, TTestQDAC {$endif} ]); end; procedure TTestJSONBenchmarking.BigContent; begin AddCase([TTestDepthContent,TTestTableContent]); AddCase(TTestHugeContent); ................................................................................ ' "GlossSee": "markup"' + #13#10 + '}' + #13#10 + '}' + #13#10 + '}' + #13#10 + '}' + #13#10 + '}'; {$ifdef ISDELPHI2010} {$RTTI EXPLICIT FIELDS([vcPublic])} // needed e.g. on Delphi XE4 {$endif} type TGlossary = packed record glossary: record title: string; ................................................................................ 'para string;GlossSeeAlso array of string}GlossSee string}}}}}'; procedure TTestSynopseRecord.Read; var gloss: TGlossary; i: integer; json: RawUTF8; begin {$ifndef ISDELPHI2010} TTextWriter.RegisterCustomJSONSerializerFromText(TypeInfo(TGlossary),__TGlossary); {$endif} for i := 1 to SAMPLE_JSON_1_COUNT do begin json := SAMPLE_JSON_1; RecordLoadJSON(gloss,@json[1],TypeInfo(TGlossary)); Check(gloss.glossary.title='example glossary'); end; ................................................................................ check(Hash32(json)=$293BAAA1); end; obj.Free; end; {$endif USEQDAC} {$ifdef USEDBXJSON} { TTestDBXJSON } {$ifndef ISDELPHIXE6} type // DBXJSON is indeed an half-backed library! ................................................................................ values: array of array of TGeoJSONCoord; multipolygon: boolean; end; TGeoJSONObjectType = ( Point,MultiPoint,LineString,MultiLineString, Polygon,MultiPolygon,GeometryCollection, Feature,FeatureCollection); {$ifdef ISDELPHI2010} TCity = packed record &type: TGeoJSONObjectType; features: array of record &type: TGeoJSONObjectType; properties: record // we may define a variant here (TDocVariant) MAPBLKLOT, BLKLOT, BLOCK_NUM, LOT_NUM: RawUTF8; FROM_ST, TO_ST, STREET, ST_TYPE, ODD_EVEN: RawUTF8; ................................................................................ ' properties{MAPBLKLOT, BLKLOT, BLOCK_NUM, LOT_NUM: RawUTF8;'+ 'FROM_ST, TO_ST, STREET, ST_TYPE, ODD_EVEN: RawUTF8}'+ 'geometry{type TGeoJSONObjectType coordinates array of TGeoJSONCoords}]'; function TTestHugeContent.GeoJSONCoordReader(P: PUTF8Char; var aValue; out aValid: Boolean): PUTF8Char; var V: TGeoJSONCoords absolute aValue; i1,i2: integer; begin // '[ [ -122.420540559229593, 37.805963600244901, 0.0 ], ... ]' aValid := false; result := nil; if (P=nil) or (P^<>'[') then exit; P := GotoNextNotSpace(P+1); if P^<>'[' then ................................................................................ P := GotoNextNotSpace(P+1); V.multipolygon := true; end else begin SetLength(V.values,1); V.multipolygon := false; end; for i1 := 0 to high(V.values) do begin SetLength(V.values[i1],JSONArrayCount(P)); for i2 := 0 to high(V.values[i1]) do begin P := GotoNextNotSpace(P); if P^<>'[' then exit; inc(P); V.values[i1,i2].x := GetNextItemDouble(P); V.values[i1,i2].y := GetNextItemDouble(P); V.values[i1,i2].z := GetNextItemDouble(P,']'); if P=nil then exit; if P^=',' then inc(P); end; if V.multipolygon then begin P := GotoNextNotSpace(P); if P^<>']' then exit; P := GotoNextNotSpace(P+1); if P^=',' then begin P := GotoNextNotSpace(P+1); if P^<>'[' then ................................................................................ end; end; aWriter.CancelLastComma; aWriter.Add(']',']'); end; procedure TTestHugeContent.SynopseBeautifier; var json,new: RawUTF8; begin json := StringFromFile(fFileName); Owner.TestTimer.Start; new := JSONReformat(json,jsonHumanReadable); check(length(new)>length(json)); json := ''; fRunConsoleMemoryUsed := MemoryUsed-fMemoryAtStart; end; procedure TTestHugeContent.SynopseReadRecord; var json: RawUTF8; data: TCity; begin TTextWriter.RegisterCustomJSONSerializer(TypeInfo(TGeoJSONCoords),GeoJSONCoordReader,GeoJSONCoordWriter); {$ifndef ISDELPHI2010} TTextWriter.RegisterCustomJSONSerializerFromTextSimpleType(TypeInfo(TGeoJSONObjectType)); TTextWriter.RegisterCustomJSONSerializerFromText(TypeInfo(TCity),__TCity); {$endif} json := StringFromFile(fFileName); Owner.TestTimer.Start; RecordLoadJSON(data,pointer(JSON),TypeInfo(TCity)); json := ''; {$ifdef ISDELPHI2010} check(data.&type=FeatureCollection); {$else} check(data._type=FeatureCollection); {$endif} fRunConsoleOccurenceNumber := length(data.features); if data.features<>nil then with data.features[high(data.features)] do begin ................................................................................ check(fRunConsoleOccurenceNumber=206560); json := ''; fRunConsoleMemoryUsed := MemoryUsed-fMemoryAtStart; obj.Free; end; {$endif} { TTestDepthContent } procedure TTestDepthContent.DownloadFilesIfNecessary; begin fRunConsoleOccurenceNumber := 3315; // line numbers in file fFileName := 'sample.json'; ................................................................................ GetValue('key').Value='wrong value'); json := ''; fRunConsoleMemoryUsed := MemoryUsed-fMemoryAtStart; obj.Free; end; {$endif} { TTestTableContent } type TSQLRecordPeople = class(TSQLRecord) private fData: TSQLRawBlob; ................................................................................ Check((ItemByName('RowID').AsInteger>11011) or (ItemByName('Data').AsString<>'')); end; check(fRunConsoleOccurenceNumber>8000); fRunConsoleMemoryUsed := MemoryUsed-fMemoryAtStart; obj.Free; end; {$endif} {$ifdef USEDBXJSON} procedure TTestTableContent.DBXJSON; var json: UTF8String; obj: TJSONArray; i: integer; begin |
> > > | > > > > > > > > > > > > > > > > > > > > > > > > > | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | > | | | | | < | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > |
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 .. 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 .. 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 ... 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 ... 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 ... 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 ... 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 ... 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 ... 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 ... 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 ... 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 .... 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 .... 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 .... 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 .... 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 .... 1290 1291 1292 1293 1294 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 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 .... 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 .... 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 |
{$I Synopse.inc} // download from https://code.google.com/p/superobject {.$define USESUPEROBJECT} {$ifdef ISDELPHI2010} {$define USEENHANCEDRTTIFORRECORDS} // 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} // SuperObject just explodes under Win64 :( {$undef USEXSUPEROBJECT} // XSuperObject just explodes under Win64 :( {$endif} {$ifdef ISDELPHI2010} // download from https://code.google.com/p/dwscript {.$define USEDWSJSON} // download from https://github.com/ahausladen/JsonDataObjects {.$define USEJDO} {$endif} {$ifdef ISDELPHIXE} // Delphi 2010 DBXJSON is just buggy and not workable {.$define USEDBXJSON} {$endif} {$define TESTBSON} uses {$I SynDprUses.inc} // link FastMM4 for older versions of Delphi Windows, ................................................................................ {$endif} {$ifdef USESUPEROBJECT} superobject, {$endif} {$ifdef USEDWSJSON} dwsJSON, {$endif} {$ifdef USEJDO} JsonDataObjects, {$endif} {$ifdef USEDBXJSON} {$ifdef ISDELPHIXE6} JSON, {$else} DBXJSON, {$endif} {$endif} ................................................................................ TTestdwsJSON = class(TSynTestCase) published procedure Read; procedure Access; procedure Write; end; {$endif} {$ifdef USEJDO} TTestJsonDataObjects = class(TSynTestCase) published procedure Read; procedure Access; procedure Write; end; {$endif} {$ifdef USEQDAC} TTestQDAC = class(TSynTestCase) published procedure Read; procedure Access; procedure Write; ................................................................................ {$endif} {$ifdef USEDWSJSON} procedure dwsJSONRead; {$endif} {$ifdef USEDBXJSON} procedure DBXJSONRead; {$endif} {$ifdef USEJDO} procedure JsonDataObjectsRead; {$endif} {$ifdef USEQDACFIXED} // QDAC is not able to parse "" as key :( procedure QDACRead; {$endif} end; TTestTableContent = class(TTestBigContentRead) protected ................................................................................ {$endif} {$ifdef USEDWSJSON} procedure dwsJSON; {$endif} {$ifdef USEDBXJSON} procedure DBXJSON; {$endif} {$ifdef USEJDO} procedure _JsonDataObjects; {$endif} {$ifdef USEQDAC} procedure QDAC; {$endif} end; TTestHugeContent = class(TTestBigContentRead) protected ................................................................................ {$endif} {$ifdef USEDWSJSON} procedure dwsJSONRead; {$endif} {$ifdef USEDBXJSON} procedure DBXJSONRead; {$endif} {$ifdef USEJDO} procedure JsonDataObjectsRead; procedure JsonDataObjectsBeautifier; {$endif} {$ifdef USEQDAC} procedure QDACRead; {$endif} end; implementation ................................................................................ {$endif} {$ifdef USEDBXJSON}, TTestDBXJSON {$endif} {$ifdef USEQDAC}, TTestQDAC {$endif} {$ifdef USEJDO}, TTestJsonDataObjects {$endif} ]); end; procedure TTestJSONBenchmarking.BigContent; begin AddCase([TTestDepthContent,TTestTableContent]); AddCase(TTestHugeContent); ................................................................................ ' "GlossSee": "markup"' + #13#10 + '}' + #13#10 + '}' + #13#10 + '}' + #13#10 + '}' + #13#10 + '}'; {$ifdef USEENHANCEDRTTIFORRECORDS} {$RTTI EXPLICIT FIELDS([vcPublic])} // needed e.g. on Delphi XE4 {$endif} type TGlossary = packed record glossary: record title: string; ................................................................................ 'para string;GlossSeeAlso array of string}GlossSee string}}}}}'; procedure TTestSynopseRecord.Read; var gloss: TGlossary; i: integer; json: RawUTF8; begin {$ifndef USEENHANCEDRTTIFORRECORDS} TTextWriter.RegisterCustomJSONSerializerFromText(TypeInfo(TGlossary),__TGlossary); {$endif} for i := 1 to SAMPLE_JSON_1_COUNT do begin json := SAMPLE_JSON_1; RecordLoadJSON(gloss,@json[1],TypeInfo(TGlossary)); Check(gloss.glossary.title='example glossary'); end; ................................................................................ check(Hash32(json)=$293BAAA1); end; obj.Free; end; {$endif USEQDAC} {$ifdef USEJDO} procedure TTestJsonDataObjects.Read; var obj: JsonDataObjects.TJsonBaseObject; i: integer; begin for i := 1 to SAMPLE_JSON_1_COUNT do begin obj := TJsonBaseObject.ParseUtf8(SAMPLE_JSON_1); check((obj as JsonDataObjects.TJsonObject).O['glossary'].S['title']='example glossary'); obj.Free; end; end; procedure TTestJsonDataObjects.Access; var obj: JsonDataObjects.TJsonBaseObject; doc: JsonDataObjects.TJsonObject; i: integer; begin obj := TJsonBaseObject.ParseUtf8(SAMPLE_JSON_1); doc := obj as JsonDataObjects.TJsonObject; Owner.TestTimer.Start; for i := 1 to SAMPLE_JSON_1_COUNT do begin Check(doc.O['glossary'].S['title']='example glossary'); Check(doc.O['glossary'].O['GlossDiv'].O['GlossList']. O['GlossEntry'].O['GlossDef'].A['GlossSeeAlso'].S[0]='GML'); end; obj.Free; end; procedure TTestJsonDataObjects.Write; var obj: JsonDataObjects.TJsonBaseObject; doc: JsonDataObjects.TJsonObject; i: integer; json: RawUTF8; begin obj := TJsonBaseObject.ParseUtf8(SAMPLE_JSON_1); doc := obj as JsonDataObjects.TJsonObject; Owner.TestTimer.Start; for i := 1 to SAMPLE_JSON_1_COUNT do begin StringToUTF8(doc.ToJSON,json); check(Hash32(json)=$293BAAA1); end; obj.Free; end; {$endif} {$ifdef USEDBXJSON} { TTestDBXJSON } {$ifndef ISDELPHIXE6} type // DBXJSON is indeed an half-backed library! ................................................................................ values: array of array of TGeoJSONCoord; multipolygon: boolean; end; TGeoJSONObjectType = ( Point,MultiPoint,LineString,MultiLineString, Polygon,MultiPolygon,GeometryCollection, Feature,FeatureCollection); {$ifdef USEENHANCEDRTTIFORRECORDS} TCity = packed record &type: TGeoJSONObjectType; features: array of record &type: TGeoJSONObjectType; properties: record // we may define a variant here (TDocVariant) MAPBLKLOT, BLKLOT, BLOCK_NUM, LOT_NUM: RawUTF8; FROM_ST, TO_ST, STREET, ST_TYPE, ODD_EVEN: RawUTF8; ................................................................................ ' properties{MAPBLKLOT, BLKLOT, BLOCK_NUM, LOT_NUM: RawUTF8;'+ 'FROM_ST, TO_ST, STREET, ST_TYPE, ODD_EVEN: RawUTF8}'+ 'geometry{type TGeoJSONObjectType coordinates array of TGeoJSONCoords}]'; function TTestHugeContent.GeoJSONCoordReader(P: PUTF8Char; var aValue; out aValid: Boolean): PUTF8Char; var V: TGeoJSONCoords absolute aValue; i1,i2,n: integer; begin // '[ [ -122.420540559229593, 37.805963600244901, 0.0 ], ... ]' aValid := false; result := nil; if (P=nil) or (P^<>'[') then exit; P := GotoNextNotSpace(P+1); if P^<>'[' then ................................................................................ P := GotoNextNotSpace(P+1); V.multipolygon := true; end else begin SetLength(V.values,1); V.multipolygon := false; end; for i1 := 0 to high(V.values) do begin n := JSONArrayCount(P); SetLength(V.values[i1],n); for i2 := 0 to n-1 do begin P := GotoNextNotSpace(P); if P^<>'[' then exit; inc(P); V.values[i1,i2].x := GetNextItemDouble(P); V.values[i1,i2].y := GetNextItemDouble(P); V.values[i1,i2].z := GetNextItemDouble(P,']'); if P=nil then exit; if P^=',' then inc(P); end; if V.multipolygon then begin P := GotoNextNotSpace(P); if P^<>']' then exit; P := GotoNextNotSpace(P+1); if P^=',' then begin P := GotoNextNotSpace(P+1); if P^<>'[' then ................................................................................ end; end; aWriter.CancelLastComma; aWriter.Add(']',']'); end; procedure TTestHugeContent.SynopseBeautifier; var json: RawUTF8; begin json := StringFromFile(fFileName); Owner.TestTimer.Start; check(JSONBufferReformatToFile(pointer(json),'testsynopse.json',jsonHumanReadable)); json := ''; fRunConsoleMemoryUsed := MemoryUsed-fMemoryAtStart; end; procedure TTestHugeContent.SynopseReadRecord; var json: RawUTF8; data: TCity; begin TTextWriter.RegisterCustomJSONSerializer(TypeInfo(TGeoJSONCoords),GeoJSONCoordReader,GeoJSONCoordWriter); {$ifndef USEENHANCEDRTTIFORRECORDS} TTextWriter.RegisterCustomJSONSerializerFromTextSimpleType(TypeInfo(TGeoJSONObjectType)); TTextWriter.RegisterCustomJSONSerializerFromText(TypeInfo(TCity),__TCity); {$endif} json := StringFromFile(fFileName); Owner.TestTimer.Start; RecordLoadJSON(data,pointer(JSON),TypeInfo(TCity)); json := ''; {$ifdef USEENHANCEDRTTIFORRECORDS} check(data.&type=FeatureCollection); {$else} check(data._type=FeatureCollection); {$endif} fRunConsoleOccurenceNumber := length(data.features); if data.features<>nil then with data.features[high(data.features)] do begin ................................................................................ check(fRunConsoleOccurenceNumber=206560); json := ''; fRunConsoleMemoryUsed := MemoryUsed-fMemoryAtStart; obj.Free; end; {$endif} {$ifdef USEJDO} procedure TTestHugeContent.JsonDataObjectsRead; var json: UTF8String; obj: JsonDataObjects.TJsonObject; begin json := StringFromFile(fFileName); Owner.TestTimer.Start; obj := JsonDataObjects.TJsonBaseObject.ParseUTF8(json) as JsonDataObjects.TJsonObject; Check(obj.S['type']='FeatureCollection'); fRunConsoleOccurenceNumber := obj.A['features'].Count; check(fRunConsoleOccurenceNumber=206560); json := ''; fRunConsoleMemoryUsed := MemoryUsed-fMemoryAtStart; obj.Free; end; procedure TTestHugeContent.JsonDataObjectsBeautifier; var json: UTF8String; // output: string; new: RawUTF8; obj: JsonDataObjects.TJsonObject; begin json := StringFromFile(fFileName); Owner.TestTimer.Start; obj := JsonDataObjects.TJsonBaseObject.ParseUTF8(json) as JsonDataObjects.TJsonObject; { output := obj.ToJSON(false); // is raising an OutOfMemory under Win32 -> file StringToUTF8(output,new); check(length(new)>length(json)); output := ''; } obj.SaveToFile('testjdo.json',false); fRunConsoleMemoryUsed := MemoryUsed-fMemoryAtStart; obj.Free; end; {$endif} { TTestDepthContent } procedure TTestDepthContent.DownloadFilesIfNecessary; begin fRunConsoleOccurenceNumber := 3315; // line numbers in file fFileName := 'sample.json'; ................................................................................ GetValue('key').Value='wrong value'); json := ''; fRunConsoleMemoryUsed := MemoryUsed-fMemoryAtStart; obj.Free; end; {$endif} {$ifdef USEJDO} procedure TTestDepthContent.JsonDataObjectsRead; var json: UTF8String; obj: JsonDataObjects.TJsonObject; begin json := StringFromFile(fFileName); Owner.TestTimer.Start; obj := JsonDataObjects.TJsonBaseObject.ParseUTF8(json) as JsonDataObjects.TJsonObject; check(obj.O['a'].O['obj'].S['key']='wrong value'); json := ''; fRunConsoleMemoryUsed := MemoryUsed-fMemoryAtStart; obj.Free; end; {$endif} { TTestTableContent } type TSQLRecordPeople = class(TSQLRecord) private fData: TSQLRawBlob; ................................................................................ Check((ItemByName('RowID').AsInteger>11011) or (ItemByName('Data').AsString<>'')); end; check(fRunConsoleOccurenceNumber>8000); fRunConsoleMemoryUsed := MemoryUsed-fMemoryAtStart; obj.Free; end; {$endif} {$ifdef USEJDO} procedure TTestTableContent._JsonDataObjects; var arr: JsonDataObjects.TJsonArray; i: integer; begin arr := JsonDataObjects.TJsonBaseObject.ParseFromFile(fFileName) as JsonDataObjects.TJsonArray; fRunConsoleOccurenceNumber := arr.Count; for i := 0 to fRunConsoleOccurenceNumber-1 do with arr.O[i] do begin Check(S['FirstName']<>''); Check(S['LastName']<>''); Check(I['YearOfBirth']<10000); Check((I['YearOfDeath']>1400)and(I['YearOfDeath']<2000)); Check((I['RowID']>11011) or (S['Data']<>'')); end; check(fRunConsoleOccurenceNumber>8000); fRunConsoleMemoryUsed := MemoryUsed-fMemoryAtStart; arr.Free; end; {$endif} {$ifdef USEDBXJSON} procedure TTestTableContent.DBXJSON; var json: UTF8String; obj: TJSONArray; i: integer; begin |
Changes to SynopseCommit.inc.
1 |
'1.18.905'
|
| |
1 |
'1.18.906'
|