tempo_inicial = $this->get_microtime(); $this->tempo_ultimo = $this->tempo_inicial; $this->tempo_total = 0; } function get_microtime() { list( $usec, $sec ) = explode( " ", microtime() ); return $usec + $sec; } function getTempoTotal() { return $this->tempo_total; } function marca( $str_nome = "" ) { if( ! $str_nome ) { $str_nome = "checkpoint " . count( $this->tomadas ) + 1; } $mictime = $this->get_microtime(); $this->tomadas[] = array( "nome" => $str_nome, "tempo_absoluto" => $mictime - $this->tempo_inicial, "diferenca_ultimo" => $mictime - $this->tempo_ultimo, "mictime" => $mictime ); $this->tempo_ultimo = $mictime; $this->tempo_total = $this->tempo_ultimo - $this->tempo_inicial; } function get_tabela( $html = false) { if( $html ) { $retorno = ""; foreach ( $this->tomadas AS $tomada ) { $retorno .= ""; $retorno .= ""; $retorno .= ""; $retorno .= ""; $retorno .= ""; $retorno .= ""; } $retorno .= "
NomeTempo AbsolutoDiferenca UltimoMicroTime
{$tomada["nome"]}" . number_format( $tomada["tempo_absoluto"], 10, ",", "." ) . "" . number_format( $tomada["diferenca_ultimo"], 10, ",", "." ) . "{$tomada["mictime"]}
"; } else { $retorno = "\n\nCronometro\n"; foreach ( $this->tomadas AS $tomada ) { $retorno .= "\tnome: {$tomada["nome"]}\n"; $retorno .= "\ttempo absoluto: " . number_format( $tomada["tempo_absoluto"], 10, ",", "." ) . "\n"; $retorno .= "\tdiferenca ultimo: " . number_format( $tomada["diferenca_ultimo"], 10, ",", "." ) . "\n"; $retorno .= "\tmicrotime: {$tomada["mictime"]}\n\n"; } } return $retorno; } } ?>