Skip to content

Instantly share code, notes, and snippets.

@mgng
Created May 8, 2009 08:05
Show Gist options
  • Save mgng/108706 to your computer and use it in GitHub Desktop.
Save mgng/108706 to your computer and use it in GitHub Desktop.
簡易計測
<?php
// 簡易計測クラス
class Keisoku
{
private static $_m = 0;
private static $_t = 0;
public static function start(){
self::$_t = microtime(true);
self::$_m = memory_get_usage(true);
}
public static function end(){
self::$_t = microtime(true) - self::$_t;
self::$_m = memory_get_usage(true) - self::$_m;
}
public static function out(){
self::$_t = (self::$_t>0.0001)? self::$_t : 0;
echo 'time : ' . self::$_t . " sec\n";
echo 'mem : ' . self::$_m/1000/1000 . " Mbyte\n";
}
}
Keisoku::start();
// 何か処理
for($i=0, $arr=array(); $i<10000; $i++){
$arr[]=$i;
}
Keisoku::end();
Keisoku::out();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment