Created
May 8, 2009 08:05
-
-
Save mgng/108706 to your computer and use it in GitHub Desktop.
簡易計測
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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