벤치마크(benchmark) Sample

<?php
/**
 * Benchmark Class
 *
 * Created on 2011. 11. 16.
 * @author 불의회상 <hoksi2k@hanmail.net>
 * @package library
 * @subpackage controllers
 * @version 1.0
 */
class Benchmark_lib extends CI_Controller {
	function __construct() {
		parent::__construct();
	}
	
	function index() {
		$this->benchmark->mark('code_start');
		$sum = 0;
		for($i=1; $i <= 1000; $i++) $sum += $i;
		$this->benchmark->mark('code_end');
		
		$data['code'] = $this->benchmark->elapsed_time('code_start', 'code_end');
		
		$this->benchmark->mark('dog');
		$sum = 0;
		for($i=1; $i <= 1000; $i++) $sum += $i;

		$this->benchmark->mark('cat');
		$sum = 0;
		for($i=1; $i <= 1000; $i++) $sum += $i;
		
		$this->benchmark->mark('bird');
		$sum = 0;
		for($i=1; $i <= 1000; $i++) $sum += $i;
		
		$data['dog_cat'] =  $this->benchmark->elapsed_time('dog', 'cat');
		$data['cat_bird'] = $this->benchmark->elapsed_time('cat', 'bird');
		$data['dog_bird'] = $this->benchmark->elapsed_time('dog', 'bird');
		
		$this->load->view('benchmark_lib_sample', $data);
	}
}
<?php $this->load->view('inc/header')?>

<table class="tablesorter" border="0" cellpadding="0" cellspacing="1">
<thead>
<tr>
  <th style="text-align:center" width="20%">구간</th>
  <th width="80%">벤치마크</th>
</tr>
</thead>
<tr>
	<td>code_start ~ code_end</td>
	<td><?php echo $code?></td>
</tr>
<tr>
	<td>dog ~ cat</td>
	<td><?php echo $dog_cat?></td>
</tr>
<tr>
	<td>cat ~ bird</td>
	<td><?php echo $cat_bird?></td>
</tr>
<tr>
	<td>dog ~ bird</td>
	<td><?php echo $dog_bird?></td>
</tr>
<tr>
	<td>전체수행시간</td>
	<td><?php echo $this->benchmark->elapsed_time();?></td>
</tr>
<tr>
	<td>전체수행시간(축약코드)</td>
	<td>0.0064</td>
</tr>
<tr>
	<td>메모리 사용량</td>
	<td><?php echo $this->benchmark->memory_usage();?></td>
</tr>
<tr>
	<td>메모리 사용량 (축약코드)</td>
	<td>0.53MB</td>
</tr>
</table>

<?php $this->load->view('inc/footer')?>

© Copyright by hoksi(Page rendered in 0.0064 seconds)