本文整理汇总了PHP中Benchmark类的典型用法代码示例。如果您正苦于以下问题:PHP Benchmark类的具体用法?PHP Benchmark怎么用?PHP Benchmark使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Benchmark类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: testDumpReturnArrayWithMarks
function testDumpReturnArrayWithMarks()
{
$benchmark = new Benchmark();
$a = $benchmark->add_mark("Start test");
$b = $benchmark->remove_mark($a);
$c = $benchmark->dump();
$this->assertIsA($c, array());
}
开发者ID:hurrycane,项目名称:framework,代码行数:8,代码来源:benchmark_tests.php
示例2: main
function main()
{
// Read number of queries to run from URL parameter
$query_count = 1;
if (!empty($_GET['queries'])) {
$query_count = intval($_GET['queries']);
}
// Fix the queries limits
$query_count = $query_count < 1 ? 1 : ($query_count > 500 ? 500 : $query_count);
$b = new Benchmark();
$b->bench_updates($query_count);
}
开发者ID:PermeAgility,项目名称:FrameworkBenchmarks,代码行数:12,代码来源:updates.php
示例3: getInstance
/**
* Sigleton
*
* @return Benchmark object
* @author Danillo César de Oliveira Melo
*/
public static function getInstance()
{
if (!isset(self::$instance)) {
self::$instance = new Benchmark();
}
return self::$instance;
}
开发者ID:jairobjunior,项目名称:cms_framework,代码行数:13,代码来源:Benchmark.php
示例4: init
private static function init()
{
self::$initialized = true;
$root_benchmark = new Benchmark(null, null);
self::$opened_benchmarks = array();
self::$opened_benchmarks[] = $root_benchmark;
}
开发者ID:mbcraft,项目名称:frozen,代码行数:7,代码来源:Benchmark.class.php
示例5: show_load_time
function show_load_time($layout)
{
$layout .= '<style type="text/css">
div.cms_debug{
background-color: white;
position: fixed;
bottom:0;
-moz-box-shadow:0 -1px 4px #000;
box-shadow:0 -1px 4px #000;
-webkit-box-shadow:0 -1px 4px #000;
padding: 2px 4px 0 4px;
left:10px;
opacity:0.3;
}
div.cms_debug:hover{
opacity:1;
}
</style>';
Benchmark::stop('Load Time');
$layout .= '<div class="cms_debug">';
foreach (Benchmark::get_totals() as $total) {
$layout .= $total . '<br>';
}
$layout .= '</div>';
}
开发者ID:sook,项目名称:drumon_framework,代码行数:25,代码来源:init.php
示例6: getAllMarks
public static function getAllMarks()
{
$bench = Benchmark::factory();
$result = array();
foreach ($bench->getMarks() as $k => $timer) {
$result[$k] = $bench->getMark($timer->getName());
}
return $result;
}
开发者ID:danelsan,项目名称:benchmark,代码行数:9,代码来源:Bench.php
示例7: execute
/**
* Starts the execution. Root path is passed to avoid recalculation.
*
*/
public static function execute()
{
// Register autoloader:
spl_autoload_register(array('\\Sifo\\Bootstrap', 'includeFile'));
// Set paths:
self::$root = ROOT_PATH;
self::$application = dirname(__FILE__);
Benchmark::getInstance()->timingStart();
self::dispatch(self::$script_controller);
Benchmark::getInstance()->timingStop();
}
开发者ID:ninodafonte,项目名称:SIFO,代码行数:15,代码来源:CLBootstrap.php
示例8: benchmarks
/**
* Database query benchmarks.
*
* @return void
*/
public function benchmarks()
{
$benchmarks = Benchmark::get(TRUE);
// Moves the first benchmark (total execution time) to the end of the array
$benchmarks = array_slice($benchmarks, 1) + array_slice($benchmarks, 0, 1);
$table = array();
$table[] = array('Benchmark', 'Time', 'Memory');
foreach ($benchmarks as $name => $benchmark) {
// Clean unique id from system benchmark names
$name = ucwords(str_replace(array('_', '-'), ' ', str_replace(SYSTEM_BENCHMARK . '_', '', $name)));
$table[] = array($name, number_format($benchmark['time'], 3), number_format($benchmark['memory'] / 1024 / 1024, 2) . 'MB');
}
$this->firephp->fb(array(count($benchmarks) . ' benchmarks took ' . number_format($benchmark['time'], 3) . ' seconds and used up ' . number_format($benchmark['memory'] / 1024 / 1024, 2) . 'MB' . ' memory', $table), FirePHP::TABLE);
}
开发者ID:NaszvadiG,项目名称:codeigniter-debug-toolbar,代码行数:19,代码来源:Fire_Profiler.php
示例9: add_as_author_of
public function add_as_author_of(User_Model $author, ORM $object)
{
if ($this->is_possible_to_add_authors_to($object)) {
Benchmark::start('add_as_author_of');
try {
$database = new Database();
$database->from('workshop_data');
$database->set(array('object_name' => $object->object_name, 'user_id' => $author->id, 'object_id' => $object->id));
$database->insert();
} catch (Kohana_Database_Exception $e) {
if (strstr($e->getMessage(), 'Duplicate entry')) {
throw new Workshop_Duplicate_Author_Exception($author, $object);
} else {
throw $e;
}
}
Benchmark::stop('add_as_author_of');
} else {
throw new Workshop_Max_Limit_Exception($object, $this->get_number_of_authors_of($object), 1, $this->config_delegate->max_authors_for($object));
}
}
开发者ID:vitrinephp,项目名称:Vitrine-PHP,代码行数:21,代码来源:Workshop.php
示例10: display
static function display()
{
$status = array('requested url' => SE::getCurrentUrl(), 'controller' => SE::getController(), 'action' => SE::getAction(), 'params' => 'array(' . join(', ', SE::getParams()) . ')', 'request method' => Request::method());
self::displayTable($status, 'Dispatcher status');
$markers = array();
$old_mark = '';
foreach (Benchmark::$mark as $mark => $time) {
$markers[$mark] = Benchmark::time($old_mark, $mark);
$old_mark = $mark;
}
self::displayTable($markers, 'Benchmark');
if (!empty($_GET)) {
self::displayTable($_GET, 'GET');
}
if (!empty($_POST)) {
self::displayTable($_POST, 'POST');
}
if (!empty($_COOKIE)) {
self::displayTable($_COOKIE, 'COOKIE');
}
self::displayTable($_SERVER, 'SERVER');
}
开发者ID:silentworks,项目名称:the-compressor,代码行数:22,代码来源:Profiler.php
示例11: save_results
/**
* Saves the benchmark results to a database
* @todo Use the database libraries for this instead of platform-specific DB calls
*
* @return void
*/
public static function save_results()
{
// Ignore all of these actions if we have benchmarking disabled
if (Kohana::config('benchmark.enable') === FALSE) {
return FALSE;
}
// Connect to the benchmark database
$db = Kohana::config('benchmark.db');
$link = mysql_connect($db['host'], $db['user'], $db['pass']) or die('Could not connect to benchmark database.');
mysql_select_db($db['database']) or die('Could not select benchmark database.');
$table = mysql_real_escape_string($db['table_prefix']) . 'benchmark';
$benchmark_results = Benchmark::get(TRUE);
foreach ($benchmark_results as $name => $data) {
// Don't save the generic system benchmark results
if (strstr($name, 'system_benchmark_') === FALSE) {
$query = 'INSERT INTO ' . $table . ' (`name`, `time`, `memory`) VALUES (\'' . mysql_real_escape_string($name) . '\', \'' . mysql_real_escape_string($data['time']) . '\', \'' . mysql_real_escape_string($data['memory']) . '\');';
// Execute the query
mysql_query($query, $link);
}
}
// Close the connection to the Benchmar DB
mysql_close($link);
}
开发者ID:Dirichi,项目名称:Ushahidi_Web,代码行数:29,代码来源:Benchmark.php
示例12: echo_formatted_data
private function echo_formatted_data($data, $datatype)
{
Benchmark::start('echo_formatted_data');
switch (strtolower($datatype)) {
case 'json':
header('Content-type: application/json');
$json = json_encode($data);
$callback = $this->input->get('jsonp_callback');
if ($callback) {
echo $callback . '(' . $json . ');';
} else {
echo $json;
}
break;
case 'xml':
header('Content-type: application/xml');
$xml = '<?xml version="1.0" encoding="UTF-8"?><result></result>';
$xml = simplexml_load_string($xml);
$this->create_xml_object($xml, $data);
$dom = new DOMDocument('1.0');
$dom->preserveWhiteSpace = false;
$dom->formatOutput = true;
$dom->loadXML($xml->asXML());
echo $dom->saveXML();
break;
case 'csv':
header('Content-type: text/csv');
$outstream = fopen("php://output", 'w');
if (!isset($data[0])) {
$data = current($data);
}
$firstElm = current($data);
if (!isset($firstElm[0])) {
fputcsv($outstream, array_keys(get_object_vars(current(current($data)))), ',', '"');
} else {
fputcsv($outstream, array_keys(get_object_vars(current($data))), ',', '"');
}
function __outputCSV(&$vals, $key, $filehandler)
{
if (!isset($vals[0])) {
fputcsv($filehandler, get_object_vars(current($vals)), ',', '"');
} else {
fputcsv($filehandler, get_object_vars($vals), ',', '"');
}
}
array_walk($data, '__outputCSV', $outstream);
fclose($outstream);
break;
default:
throw new Kohana_404_Exception();
break;
}
Benchmark::stop('echo_formatted_data');
}
开发者ID:jverkoey,项目名称:uwdata.ca,代码行数:54,代码来源:v1.php
示例13: benchmarks
/**
* Benchmark times and memory usage from the Benchmark library.
*
* @return void
*/
public function benchmarks()
{
if (!($table = $this->table('benchmarks'))) {
return;
}
$table->add_column();
$table->add_column('kp-column kp-data');
$table->add_column('kp-column kp-data');
$table->add_row(array('Benchmarks', 'Time', 'Memory'), 'kp-title', 'background-color: #FFE0E0');
$benchmarks = Benchmark::get(TRUE);
// Moves the first benchmark (total execution time) to the end of the array
$benchmarks = array_slice($benchmarks, 1) + array_slice($benchmarks, 0, 1);
text::alternate();
foreach ($benchmarks as $name => $benchmark) {
// Clean unique id from system benchmark names
$name = ucwords(str_replace(array('_', '-'), ' ', str_replace(SYSTEM_BENCHMARK . '_', '', $name)));
$data = array($name, number_format($benchmark['time'], 3), number_format($benchmark['memory'] / 1024 / 1024, 2) . 'MB');
$class = text::alternate('', 'kp-altrow');
if ($name == 'Total Execution') {
$class = 'kp-totalrow';
}
$table->add_row($data, $class);
}
}
开发者ID:nebogeo,项目名称:borrowed-scenery,代码行数:29,代码来源:Profiler.php
示例14: array
<?php
$time = array();
$mem = array();
include 'Benchmark.php';
$benchmark = new Benchmark();
if (!empty($_POST)) {
ob_start();
foreach ($_POST['code'] as $code) {
for ($n = 0; $n < $_POST['iterations']; $n++) {
$benchmark->start();
eval($code);
$benchmark->finish();
}
$time[] = $benchmark->get_time();
$mem[] = $benchmark->get_memory();
$benchmark->flush();
}
ob_end_clean();
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>PHP Benchmark</title>
<style type="text/css">
* { margin:0; padding:0; }
body { font:90% Arial, Helvetica, sans-serif; padding:2em; }
form textarea, form input { font-family:"Courier New", Courier, monospace; }
.block { float:left; }
开发者ID:laiello,项目名称:php-benchmark-tool-and-class,代码行数:31,代码来源:index.php
示例15: die
if (!is_dir("{$repoPath}/.git")) {
die("{$repoPath} does not contain .git");
}
// get repo
chdir($repoPath);
// sync trees
foreach ($repoCfg['trees'] as $srcPath => $treeOptions) {
if (is_string($treeOptions)) {
$treeOptions = array('path' => $treeOptions);
}
$treeOptions = array_merge($exportOptions, $treeOptions, ['dataPath' => false]);
if (!is_string($srcPath)) {
$srcPath = $treeOptions['path'];
} elseif (!$treeOptions['path']) {
$treeOptions['path'] = $srcPath;
}
$srcFileNode = Site::resolvePath($srcPath);
if (is_a($srcFileNode, 'SiteFile')) {
$destDir = dirname($treeOptions['path']);
if ($destDir && !is_dir($destDir)) {
mkdir($destDir, 0777, true);
}
copy($srcFileNode->RealPath, $treeOptions['path']);
Benchmark::mark("exported file {$srcPath} to {$treeOptions['path']}");
} else {
$exportResult = Emergence_FS::exportTree($srcPath, $treeOptions['path'], $treeOptions);
Benchmark::mark("exported directory {$srcPath} to {$treeOptions['path']}: " . http_build_query($exportResult));
}
}
Benchmark::mark("wrote all changes");
开发者ID:nbey,项目名称:Emergence-Skeleton,代码行数:30,代码来源:export.php
示例16: elseif
} elseif (!$treeOptions['path']) {
$treeOptions['path'] = $srcPath;
}
$treeOptions['exclude'][] = '#(^|/)\\.git(/|$)#';
if (is_file($treeOptions['path'])) {
$sha1 = sha1_file($treeOptions['path']);
$existingNode = Site::resolvePath($srcPath);
if (!$existingNode || $existingNode->SHA1 != $sha1) {
$fileRecord = SiteFile::createFromPath($srcPath, null, $existingNode ? $existingNode->ID : null);
SiteFile::saveRecordData($fileRecord, fopen($treeOptions['path'], 'r'), $sha1);
Benchmark::mark("importing file {$srcPath} from {$treeOptions['path']}");
} else {
Benchmark::mark("skipped unchanged file {$srcPath} from {$treeOptions['path']}");
}
} else {
$cachedFiles = Emergence_FS::cacheTree($srcPath);
Benchmark::mark("precached {$srcPath}: " . $cachedFiles);
$exportResult = Emergence_FS::importTree($treeOptions['path'], $srcPath, $treeOptions);
Benchmark::mark("importing directory {$srcPath} from {$treeOptions['path']}: " . http_build_query($exportResult));
}
}
// commit changes
#$repo->git('add --all');
#
#$repo->git(sprintf(
# 'commit -n -m "%s" --author="%s <%s>"'
# ,addslashes($_POST['message'])
# ,$GLOBALS['Session']->Person->FullName
# ,$GLOBALS['Session']->Person->Email
#));
#Benchmark::mark("committed all changes");
开发者ID:nbey,项目名称:Emergence-Skeleton,代码行数:31,代码来源:pull.php
示例17: echo_formatted_data
private function echo_formatted_data($data, $datatype)
{
Benchmark::start('echo_formatted_data');
switch (strtolower($datatype)) {
case 'json':
header('Content-type: application/json');
$json = json_encode($data);
$callback = $this->input->get('jsonp_callback');
if ($callback) {
echo $callback . '(' . $json . ');';
} else {
echo $json;
}
break;
case 'xml':
header('Content-type: application/xml');
$xml = '<?xml version="1.0" encoding="UTF-8"?><result></result>';
$xml = simplexml_load_string($xml);
$this->create_xml_object($xml, $data);
$dom = new DOMDocument('1.0');
$dom->preserveWhiteSpace = false;
$dom->formatOutput = true;
$dom->loadXML($xml->asXML());
echo $dom->saveXML();
break;
default:
throw new Kohana_404_Exception();
break;
}
Benchmark::stop('echo_formatted_data');
}
开发者ID:vshulman,项目名称:uwdata.ca,代码行数:31,代码来源:v1.php
示例18: __destruct
/**
* Destrcutor
*
* Stops benchmarking
*
* @access public
*
* @author Thorsten Schmidt
* @date 10.08.2009
* @version 1.0
* @since 1.0
*/
public function __destruct()
{
Benchmark::stop('GridModule Loading');
}
开发者ID:ThorstenS,项目名称:YAG,代码行数:16,代码来源:Grid.php
示例19: Benchmark
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
// Include benchmark library
require_once '../class/benchmark.php';
// Init class
$benchmark = new Benchmark();
// Two functions to compare
// for example: switch VS ternary operator
function benchmark_compare_one()
{
$n = rand(0, 9);
$i = 0;
switch ($n) {
case 0:
$i++;
break;
case 1:
$i++;
break;
case 2:
$i++;
开发者ID:raphaelm,项目名称:php-benchmark,代码行数:31,代码来源:example.php
示例20: Query
/**
* Rewrite Query to init some debug parameters.
* @param $query_filters
* @param $sphinx_indexes
* @param string $comment
* @return bool
*/
public function Query($query_filters, $sphinx_indexes, $comment = "")
{
Benchmark::getInstance()->timingStart('search');
$sphinx_results = $this->sphinx->Query($query_filters, $sphinx_indexes, $comment);
$sphinx_time = Benchmark::getInstance()->timingCurrentToRegistry('search');
$debug_sphinx = array("tag" => $comment, "query" => $query_filters, "connection" => $this->sphinx_config['config_file'], "indexes" => $sphinx_indexes, "resultset" => $sphinx_results, "time" => $sphinx_time, "error" => $this->sphinx->_error, "controller" => $this->getCallerClass());
$debug_sphinx = array_merge($debug_sphinx, $this->query_context);
$this->query_debug['queries'][$this->query_debug['current_query']] = $debug_sphinx;
$this->query_debug['time'] = $sphinx_time;
$this->query_debug['error'] = $this->sphinx->_error;
$this->query_debug['tag'] = $comment;
$this->query_debug['total_found'] = $sphinx_results['total_found'];
$this->query_debug['returned_rows'] = isset($sphinx_results['matches']) ? count($sphinx_results['matches']) : 0;
Debug::push('searches', $this->query_debug);
unset($this->query_debug);
$this->query_debug['current_query'] = 0;
return $sphinx_results;
}
开发者ID:ninodafonte,项目名称:SIFO,代码行数:25,代码来源:Search.php
注:本文中的Benchmark类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论