On the intermediate layer server, package dataset data. The client receives the data using dataset. There are two formats:
(1) tdatasetprovider. Data Format
(2) The format obtained by ADO _ stream is called adostream format, which is also divided into adtg format and XML format.
The following tests the efficiency of ADO and dbexpress database engines in generating different formats.
The test code is as follows:
Function adoreaddata (adataset: tcustomadodataset; aformat: tpersistformat = pfadtg): variant; var vstream: _ stream; vfilter: variant; begin vstream: = costream. create; vfilter: = adataset. recordset. filter; try // remove filter adataset first. recordset. filter: = ''; If aformat = pfadtg then begin vstream. type _: = adtypebinary; adodb_tlb. _ recordset (adataset. recordset ). save (vstream, adpersistadtg); vstream. position: = 0; Result: = vstream. read (vstream. size); End else begin vstream. type _: = adtypetext; olevariant (adataset. recordset ). save (vstream, adpersistxml); vstream. position: = 0; Result: = vstream. readtext (vstream. size); end; finally vstream: = nil; adataset. recordset. filter: = vfilter; end;
Procedure tform4.button1click (Sender: tobject); const cnst_repeattimes = 10; var I: integer; A: tdatetime; vdata: variant; begin // no image // sqldataset1.commandtext: = 'select * From cssystemlogs'; // adodataset1.commandtext: = 'select * From cssystemlogs'; // sqldataset1.commandtext: = 'select * From csmachines '; adodataset1.commandtext: = 'select * From csmachines '; A: = now; for I: = 1 to cnst_repeattimes do begin sqlconnection1.open; sqldataset1.open; vdata: = datasetprovider1.data; sqldataset1.close; sqlconnection1.close; end; edit1.text: = floattostr (round (now-a) * 86400000); edit1_1.text: = inttostr (vararrayhighbound (vdata, 1); a: = now; for I: = 1 to export do begin adoconnection1.open; adodataset1.open; vdata: = allow; adodataset1.close; adoconnection1.close; end; edit2.text: = floattostr (round (now-a) * 86400000); edit2_1.text: = inttostr (vararrayhighbound (vdata, 1); a: = now; for I: = 1 to export do begin adoconnection1.open; adodataset1.open; vdata: = adoreaddata (adodataset1, pfadtg ); adodataset1.close; adoconnection1.close; end; edit3.text: = floattostr (round (now-a) * 86400000); edit3_1.text: = inttostr (vararrayhighbound (vdata, 1);: = now; for I: = 1 to cnst_repeattimes do begin adoconnection1.open; adodataset1.open; vdata: = adoreaddata (adodataset1, pfxml); adodataset1.close; adoconnection1.close; end; edit4.text: = floattostr (round (now-a) * 86400000); edit4_1.text: = inttostr (length (widestring (vdata) * 2); end;
Test results:
1. The data table contains the image field, which is packaged 10 times in a row.
Serial number |
Midas dbexpress |
Midas ado |
ADO Stream adtg |
ADO Stream XML |
Packaging time (MS ): |
1 |
468 |
610 |
594 |
108672 |
2 |
484 |
469 |
578 |
108985 |
3 |
468 |
454 |
546 |
109023 |
4 |
484 |
454 |
562 |
109434 |
5 |
485 |
453 |
562 |
109828 |
Returned data size (in bytes ): |
|
2603267 |
2603112 |
2603998 |
11186048 |
The fastest speed is "MIDAS Ado", and the smallest data is "MIDAS Ado ". The efficiency of "ADO Stream XML" is 241 times lower, and the data size is 4 times lower.
2. There is no image field in the data table, and it is packed 10 times in a row.
Serial number |
Midas dbexpress |
Midas ado |
ADO Stream adtg |
ADO Stream XML |
Packaging time (MS ): |
1 |
469 |
562 |
250 |
469 |
2 |
375 |
562 |
219 |
516 |
3 |
375 |
547 |
234 |
500 |
4 |
391 |
547 |
234 |
500 |
5 |
375 |
562 |
219 |
500 |
Returned data size (in bytes ): |
|
177732 |
156805 |
182433 |
534026 |
The fastest speed is "ADO Stream adtg", and the smallest data is "MIDAS Ado ".