CI版本是2.1.3,thinkphp用的是3.1。 php
由于大多数站点所作的事情就是查询数据库,所以这次的测试着重于数据库查询并显示。测试的数据库是dede的sys_enum,631条数据。目标就是查询出这些数据并显示到页面上计算消耗时间。<?php $begin=microtime(); $begin=microtime_float($begin); ?> <?php function microtime_float($time) { list($usec, $sec) = explode(" ", $time); return (((float)$usec + (float)$sec)*1000); } ?> <?php $link = mysql_connect('localhost', 'root', 'founder') or die('Could not connect: ' . mysql_error()); mysql_select_db('dedecmsv57utf8sp1') or die('Could not select database'); $query='SELECT * FROM dede_sys_enum'; $result = mysql_query($query) or die('Query failed: ' . mysql_error()); echo "<table width=\"416\" border=\"0\" cellpadding=\"1\" cellspacing=\"0\"><tr><td>ID</td><td>ename</td><td>egroup</td></tr>"; while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { echo "\t<tr>\n"; foreach ($line as $col_value) { echo "\t\t<td>$col_value</td>\n"; } echo "\t</tr>\n"; } echo "</table>\n"; mysql_free_result($result); mysql_close($link); $end=microtime(); $end=microtime_float($end); echo 'time:'.($end-$begin); ?>
<?php $begin=microtime(); $begin=microtime_float($begin); ?>
$end=microtime(); $end=microtime_float($end); echo 'time:'.($end-$begin); ?>
class Test extends CI_Controller { public function index() { $this->load->model('testm'); $data['test']=$this->testm->testmf(); $this->load->view('test',$data); } }
class Testm extends CI_Model { public function testmf() { $this->load->database(); $sql="SELECT * FROM dede_sys_enum"; return $this->db->query($sql); } }
<?php foreach($test->result() as $row) echo "<tr><td>".$row->id."</td><td>".$row->ename."</td><td>".$row->evalue."</td><td>".$row->egroup."</td><td>".$row->disorder."</td><td>".$row->issign."</td></tr>"; ?>
我在自建的入口文件里填写以下代码: mysql
$begin=microtime(); $begin=microtime_float($begin); function microtime_float($time) { list($usec, $sec) = explode(" ", $time); return (((float)$usec + (float)$sec)*1000); } require("./tp/ThinkPHP.php"); $end=microtime(); $end=microtime_float($end); echo 'time:'.($end-$begin);而后按要求作了action
class IndexAction extends Action { public function index(){ $Sys_enum=new Model("sys_enum"); $list =$Sys_enum->select(); $this->assign('test', $list); $this->display(); } }
还有View的关键代码以下 sql
<?php foreach($test as $row) echo "<tr><td>".$row['id']."</td><td>".$row['ename']."</td><td>".$row['evalue']."</td><td>".$row['egroup']."</td><td>".$row['disorder']."</td><td>".$row['issign']."</td></tr>"; ?>
获得10次的访问时间以下: thinkphp
11.565332031250 (PHP) 数据库
54.319799804790 (CI) 安全
132.997436523438 (ThinkPHP) 框架
ThinPHP与PHP 测试
132.997436523438/11.565332031250=11.499664355859 约等于11.5倍 fetch
那么也就是说,纯PHP是CI的4.5是ThinkPHP的11.5倍 ui
我想仍是我本身写个简单的框架吧,可以完成开发效率就OK的框架吧。