php和asp.net下SQLite3的执行速度对比
生活随笔
收集整理的這篇文章主要介紹了
php和asp.net下SQLite3的执行速度对比
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
當(dāng)看到這樣的結(jié)果時(shí),我很詫異。我以為php會(huì)更快一點(diǎn)兒,但事實(shí)是asp.net更勝一籌。不解!
php 頁(yè)面:0.5秒
asp.net 頁(yè)面 :0.4秒
php頁(yè)面源碼
<html> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><body> <?php /*** Simple function to replicate PHP 5 behaviour*/ function microtime_float() {list($usec, $sec) = explode(" ", microtime());return ((float)$usec + (float)$sec); }$time_start = microtime_float(); ?><?php $filepath="F:\MyPram\DAQ\u7pkDAQ.db3";$db=new SQLite3($filepath); //打開(kāi)此路徑數(shù)據(jù)庫(kù)文件 /* $sql="select count(ip) from downloadinfo where netbarname like '%(NEW 2012(Beta5.0))%' "; $result=$db->query($sql); //執(zhí)行查詢(xún)語(yǔ)句 $row = $result->fetchArray(); echo "<font color=blue>2012Beta 5.0總下載量:".$row[0]."</font>"; */ $sql="select NetBarName as 網(wǎng)吧名, Telephone as 電話(huà), Email as 郵箱,QQ,IP,Zone as 物理位置,Time as 使用時(shí)間, net as 網(wǎng)絡(luò)服務(wù)商 from downloadinfo where netbarname like '%(NEW 2012(Beta5.0))%' order by time desc"; //查詢(xún)記錄echo "<table cellspacing='0' cellpadding='3' rules='all' style='background-color:White;border-color:#CCCCCC;border-width:1px;border-style:None;font-size:10pt;font-weight:normal;border-collapse:collapse;'>"; printf("<tr style='color:White;background-color:#006699;font-weight:bold;'><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>\n","網(wǎng)吧名","電話(huà)","郵箱","QQ","IP","物理位置","安裝時(shí)間","服務(wù)商"); $result=$db->query($sql); //執(zhí)行查詢(xún)語(yǔ)句 while($row = $result->fetchArray()){printf("<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>\n",$row["網(wǎng)吧名"],$row[1],$row[2],$row[3],$row[4],$row[5],$row[6],$row[7]); } echo "</table>"; $db->close(); //關(guān)閉$time_end = microtime_float(); $time = $time_end - $time_start;echo "花費(fèi)時(shí)間:$time 秒\n"; ?> </body> </html>asp.net 頁(yè)面源碼
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Configuration; using System.Data; using System.Data.SQLite;namespace DAPX {public partial class DownloadList : System.Web.UI.Page{protected void Page_Load(object sender, EventArgs e){string strOutput;long iStartMs = DateTime.Now.Ticks;long iEndMs = 0;//if (!this.IsPostBack)//{ strConn = ConfigurationManager.ConnectionStrings["ConnectionString"].ToString();conn = new System.Data.SQLite.SQLiteConnection();conn.ConnectionString = strConn;conn.Open();//----------------------------------------------string strSQL = string.Empty;int index = Convert.ToInt32(Request.QueryString["index"]);switch (index){case 1:strSQL = "select NetBarName as 網(wǎng)吧名, Telephone as 電話(huà), Email as 郵箱,QQ,IP,Zone as 物理位置,Time as 使用時(shí)間, net as 網(wǎng)絡(luò)服務(wù)商 from downloadinfo where netbarname like '%(NEW2012 Beta1.0)%' order by time desc";break;case 2:strSQL = "select NetBarName as 網(wǎng)吧名, Telephone as 電話(huà), Email as 郵箱,QQ,IP,Zone as 物理位置,Time as 使用時(shí)間, net as 網(wǎng)絡(luò)服務(wù)商 from downloadinfo where netbarname like '%(NEW 2012(Beta2.0))%' order by time desc";break;case 3:strSQL = "select NetBarName as 網(wǎng)吧名, Telephone as 電話(huà), Email as 郵箱,QQ,IP,Zone as 物理位置,Time as 使用時(shí)間, net as 網(wǎng)絡(luò)服務(wù)商 from downloadinfo where netbarname like '%(NEW 2012(Beta3.0))%' order by time desc";break;case 4:strSQL = "select NetBarName as 網(wǎng)吧名, Telephone as 電話(huà), Email as 郵箱,QQ,IP,Zone as 物理位置,Time as 使用時(shí)間, net as 網(wǎng)絡(luò)服務(wù)商 from downloadinfo where netbarname like '%(NEW 2012(Beta4.0))%' order by time desc";break;case 5:strSQL = "select NetBarName as 網(wǎng)吧名, Telephone as 電話(huà), Email as 郵箱,QQ,IP,Zone as 物理位置,Time as 使用時(shí)間, net as 網(wǎng)絡(luò)服務(wù)商 from downloadinfo where netbarname like '%(NEW 2012(Beta5.0))%' order by time desc";break;default:strSQL = "select NetBarName as 網(wǎng)吧名, Telephone as 電話(huà), Email as 郵箱,QQ,IP,Zone as 物理位置,Time as 使用時(shí)間, net as 網(wǎng)絡(luò)服務(wù)商 from downloadinfo where netbarname like '%(NEW 2012(Beta5.0))%' order by time desc";break;}this.GridView1.DataSource = GetDataTable(strSQL);DataBind();//----------------------------------------------conn.Close();//}//else// DataBind();iEndMs = DateTime.Now.Ticks;strOutput = string.Format("花費(fèi)時(shí)間:{0}\n", (iEndMs - iStartMs) * System.Math.Pow(10, -7));Response.Write(strOutput);}System.Data.SQLite.SQLiteConnection conn = null;System.Data.SQLite.SQLiteDataAdapter adapter = null;System.Data.SQLite.SQLiteCommand cmd = null;string strConn = string.Empty;/// <summary>/// /// </summary>/// <returns></returns>public DataTable GetDataTable(string strSQL){// string strSQL = string.Empty;DataTable dttTmp = null;string strTmp = string.Empty;if (conn.State == ConnectionState.Open){cmd = new SQLiteCommand(conn);//總下載量//strSQL = "select count(*) from downloadinfo ";cmd.CommandText = strSQL;adapter = new SQLiteDataAdapter(cmd);dttTmp = new DataTable();adapter.Fill(dttTmp);if (dttTmp != null)return dttTmp;}return null;}} }
總結(jié)
以上是生活随笔為你收集整理的php和asp.net下SQLite3的执行速度对比的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 如何在Android模拟器上安装和卸载A
- 下一篇: 各安全浏览器如何设2345为主页