國家現在開始抓盜版了,無奈,.net平台實在是比較貴的,但又不像放棄.net,只能把.netframework換成mono,把sql server換成postgresql,剛剛著手學習
今天測試用npgsql 連postgresql的效率對比ado.net連sql server代碼很簡單:
double firstms = 0.0,secondms=0.0;
for (int i = 0; i < 1000; i++)
{
Npgsql.NpgsqlConnection conn = new NpgsqlConnection(ConnStr);
conn.Open();
conn.Close();
}
DateTime endtime=DateTime.Now;
firstms=endtime.Subtract(begintime).TotalMilliseconds;
DateTime begintime1 = DateTime.Now;
for (int i = 0; i < 1000; i++)
{
SqlConnection sqlConn = new SqlConnection(sqlConnStr);
sqlConn.Open();
sqlConn.Close();
}
DateTime endtime1 = DateTime.Now;
secondms = endtime1.Subtract(begintime1).TotalMilliseconds;
Response.Write(string.Format("postgresql:{0},mssql:{1}",firstms,secondms));
代碼很簡單,但測試結果卻不能讓人滿意:
postgresql:531.25,mssql:15.625
postgresql:515.625,mssql:15.625
postgresql:531.25,mssql:15.625
postgresql:515.625,mssql:0
postgresql:531.25,mssql:0
看來免費的東西還是不好使啊