stm32 基准计时器
One of the best parts about being a programmer is that there's seemingly always a better way to do things. A simple code tweak can drastically improve the execution time of your web application. The faster your application executes the quicker you release precious server resources.
成为程序员最好的部分之一是,似乎总是有一种更好的做事方式。 简单的代码调整可以极大地缩短Web应用程序的执行时间。 应用程序执行得越快,释放宝贵的服务器资源的速度就越快。
The first step in optimizing your existing PHP-based web application for speed is knowing which portions of your website need to be improved. Do your MySQL queries take too long? Are you using efficient functions? Are you using unnecessary server resources?
优化现有基于PHP的Web应用程序以提高速度的第一步是知道网站的哪些部分需要改进。 您MySQL查询时间是否太长? 您是否在使用高效功能? 您是否在使用不必要的服务器资源?
In my web applications I use a timer class to benchmark how long queries, functions, and entire pages are taking to complete.
在我的Web应用程序中,我使用计时器类来基准化查询,函数和整个页面花费的时间。
功能 (The Function)
class timer {
var $start;
var $pause_time;
/* start the timer */
function timer($start = 0) {
if($start) { $this->start(); }
}
/* start the timer */
function start() {
$this->start = $this->get_time();
$this->pause_time = 0;
}
/* pause the timer */
function pause() {
$this->pause_time = $this->get_time();
}
/* unpause the timer */
function unpause() {
$this->start += ($this->get_time() - $this->pause_time);
$this->pause_time = 0;
}
/* get the current timer value */
function get($decimals = 8) {
return round(($this->get_time() - $this->start),$decimals);
}
/* format the time in seconds */
function get_time() {
list($usec,$sec) = explode(' ', microtime());
return ((float)$usec + (float)$sec);
}
}
用法 (The Usage)
$timer = new timer(1); // constructor starts the timer, so no need to do it ourselves
/*
... mysql query ...
*/
$query_time = $timer->get();
/*
... page processing ...
*/
$processing_time = $timer->get();
输出 (The Output)
Once you know which areas of your website need improvement, making your code more efficient can be easy if you're code is well-commented and organized. Use the timer -- which areas of your website did you notice needed improvement and how did you optimize the code? I'd love to hear your problems and solutions!
一旦知道了网站的哪些方面需要改进,就可以轻松地提高代码效率(如果您对代码进行了很好的注释和组织)。 使用计时器-您注意到网站的哪些方面需要改进,以及如何优化代码? 我希望听到您的问题和解决方案!
stm32 基准计时器