DataSet資料傳送效能比較

2022-07-15 13:36:08 字數 1883 閱讀 5627

1、直接返回dataset物件

特點:通常元件化的處理機制,不加任何的修飾及處理。

優點:**精簡,易於處理,小資料量處理比較快。

缺點:大資料量的傳遞處理慢,消耗網路資源。

建議:當應用系統在內網、專網(區域網)或者外網(廣域網)且資料量在kb級時的應用,採用該模式。

bll:

public dataset getdataset()

{string sql ="select * from users";

sqlconnectioin con = new  sqlconnection("server=192.168.79.20;database=1212,user=sa;pwd=sa");

con.open();

sqldataadapter sa = new sqldataadapter (sql,con);

dataset ds = new dataset();

sa.fill(ds);   

con.close();

return ds;

物件呼叫:

protect  void btn_ok(object sender,eventargs e)

dataset ds =getdataset();

this.grivdview.datasoure=ds.table[0];

this.grivdview.databind();

2、返回dataset物件用binary序列化後的位元組陣列

特點:位元組陣列流的處理模式;

優點:易於處理,可以對中文內容起到加密作用。

缺點:大資料量的傳遞處理慢,較消耗網路資源。

建議:但系統需要進行較大資料交換時採用。

bll:

public byte getdatasetbyte()

{dataset ds =getdataset();//獲取dataset資料物件

binaryformatter bf = new binaryformatter();//定義二進位制

memorystream ms = new memorystream();//定義記憶體流

bf.serialize(ms, ds);//以二進位制的形式對dataset物件進行序列化,並存入到記憶體流中

byte buff = ms.toarray();//把記憶體流的資料寫入位元組陣列

return buff;

物件呼叫:

protect  void btn_ok(object sender,eventargs e)

byte buffer = getdatasetbyte();

binaryformatter bf = new binaryformatter();

dataset ds = bf.deserialize(new memorystream(buffer)) as dataset;

this.grivdview.datasoure=ds.table[0];

this.grivdview.databind();

3、返回datasetsurrogate物件,該物件採用binary序列化後的位元組陣列

特點:微軟提供的開源元件。

優點:易於處理,可以對中文內容起到加密作用。

缺點:大資料量傳遞處理慢,較消耗網路資源。

建議:但系統需要進行較大資料交換時採用。

4、返回datasetsurrogate物件,該物件採用binary序列化並zip壓縮後的位元組陣列

特點:對位元組流陣列進行壓縮後傳遞,需微軟datasetsurrogate.dll。

優點:當資料量大時,效能提高效果明顯,壓縮比例大。

缺點:相比第三方元件,壓縮比例還需有待提高。

建議:當系統需要進行大資料量網路資料傳遞時,建議採用此種可靠、高效、免費的方法。

redis memcache 效能比較

from redis和memcache非常像的,都是key,value的方式,將資料存放記憶體中。最近在學習redis,在網上看了一些這方面的資料,有三種觀點 1,redis讀寫記憶體比memcache快 2,memcache讀寫記憶體比redis快 3,memcache讀寫記憶體比redis快,但...

apache resin ngnix 效能比較

靜態頁面測試,靜態頁面包括css,js,img ab c 20 n 30 併發測試 高數值的也測過,結論一致 resin2.17 平均響應時間為0.521ms nginx 0.7.65 平均響應時間為1.042ms 少許幾次小於1.042 apache2.0 平均響應時間為最低1.042ms 在re...

tomcat效能比較

tomcat的四種基於http協議的connector效能比較 我們姑且把上面四種connector按照順序命名為 nio,http,pool,niop 為了不讓其他因素影響測試結果,我們只對乙個很簡單的jsp頁面進行測試,這個頁面僅僅是輸出乙個hello world。假設位址是 http tomc...