Efficiency of ADO, adostream, dbexpress and tdatasetprovider

Source: Internet
Author: User
Tags remove filter

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 ".

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.