/** * Returns single benchmark time in seconds * * @param string $benchmarkLambdaFunction Benchmark lambda function * @param array $benchmarkFunctionArgumentsArray Benchmark arguments array * * @return float */ function getSingleBenchmarkTimeSecs($benchmarkLambdaFunction, array $benchmarkFunctionArgumentsArray) { $autoStartTimer = 1; $timer = new Timer($autoStartTimer); call_user_func_array($benchmarkLambdaFunction, $benchmarkFunctionArgumentsArray); return $timer->get(); }
private function render($controller, $is404 = false) { $response = thin('response'); if (!$is404) { $response->setStatusCode(200, 'OK'); } else { $response->setStatusCode(404, 'Not Found'); } ob_start(); $response->sendHeaders()->setContent($this->html($controller))->send(); $html = ob_get_contents(); ob_end_clean(); die($html . '<!-- generated in ' . Timer::get() . ' s. -->'); }
public function pushToSession($account_id, array $data = []) { $session = Model::Sessionmobile()->firstOrCreate(['account_id' => (int) $account_id]); if ($session) { $session = $session->toArray(); $regid = isAke($session, 'regid', false); $socket_id = isAke($session, 'socket_id', false); // if ($regid) { // $this->send([$regid], $data); // } if ($socket_id) { $io = lib('io'); $data['id'] = $socket_id; $message = $io->emit('bump', $data); } return Timer::get(); } }
public static function finish() { $time = Timer::get(); }
public static function showStats() { Timer::stop(); $executionTime = Timer::get(); $queries = null === Utils::get('NbQueries') ? 0 : Utils::get('NbQueries'); $valQueries = $queries < 2 ? 'SQL Query executed' : 'SQL Queries executed'; $SQLDuration = null === Utils::get('SQLTotalDuration') ? 0 : Utils::get('SQLTotalDuration'); $queriesNoSQL = null === Utils::get('NbQueriesNOSQL') ? 0 : Utils::get('NbQueriesNOSQL'); $valQueriesNoSQL = $queriesNoSQL < 2 ? 'NoSQL Query executed' : 'NoSQL Queries executed'; $SQLDurationNoSQL = null === Utils::get('SQLTotalDurationNOSQL') ? 0 : Utils::get('SQLTotalDurationNOSQL'); $execPHPSQL = $executionTime - $SQLDuration; $execPHPNoSQL = $executionTime - $SQLDurationNoSQL; $execPHP = $executionTime - $SQLDuration; $PCPhp = round($execPHP / $executionTime * 100, 2); $PCPhpSQL = round($execPHPSQL / $executionTime * 100, 2); $PCPhpNoSQL = round($execPHPNoSQL / $executionTime * 100, 2); $PCSQL = 100 - $PCPhpSQL; $PCNoSQL = 100 - $PCPhpNoSQL; $included = count(get_included_files()); return "\n<!--\n\n\tPage generated in {$executionTime} s. by Thin Framework (C) www.geraldplusquellec.me 1996 - " . date('Y') . "\n\t{$queries} {$valQueries} in {$SQLDuration} s. (" . $PCSQL . " %)\n\t{$queriesNoSQL} {$valQueriesNoSQL} in {$SQLDurationNoSQL} s. (" . $PCNoSQL . " %)\n\tPHP Execution {$execPHP} s. ({$PCPhp} %)\n\n\n\n\t" . $included . " scripts included\n\tUsed Memory : " . convertSize(memory_get_usage()) . "\n\n-->"; }
} } } fclose($handle); } if ($db == NULL || $user == NULL || $pass == NULL || $host == NULL) { echo "Something went wrong trying to grab the connection data\n"; echo "db={$db}; user={$user}; pass={$pass}; host={$host}"; exit; } $db = new mysqli($host, $user, $pass, $db); if ($db->connect_errno > 0) { die("Unable to connect to the database [ " . $db->connect_error . " ]"); } echo "\n "; echo "DB connection established at \t\t" . $timer->get() . " secs\n "; $db->query("DROP TABLE IF EXISTS TEST_TBL"); $tableCreate = "CREATE TABLE TEST_TBL ( id int(11) NOT NULL auto_increment , txt TEXT , PRIMARY KEY (id))"; if ($db->query($tableCreate) === FALSE) { die("Error creating the table [ " . $db->error . " ]"); } else { echo "Table created at \t\t\t" . $timer->get() . " secs\n "; echo "Generating random data\t\t\t"; for ($i = 1; $i <= 1000; $i++) { if ($i % 66 == 0) { echo "."; } if ($i == 1000) { echo "\n "; } if (!($insert = $db->query("INSERT INTO TEST_TBL (txt) VALUES ('" . $timer->randString(25) . "')"))) {
// Show spinner phase and status $time = $timer->get(); if ($time >= 1) { $timeSpent = timeIntervalStr($timer->get()); } else { $timeSpent = '-'; } $timeSpentText = $GColors->getColoredString("[{$timeSpent}]", $GTimeTextColor); $statusText = $GColors->getColoredString($GStatusText, $GStatusTextColor); $memUsage = formatBytes(memory_get_usage(true)); $memUsageText = $GColors->getColoredString("[{$memUsage}]", 'yellow'); echo "\r{$spinnerChars[$spinnerPhase]} {$timeSpentText} {$memUsageText} {$statusText}"; // Change phase $spinnerPhase = $spinnerPhase < count($spinnerChars) - 1 ? $spinnerPhase + 1 : 0; }); $GScriptTimer = new Timer(1); register_shutdown_function(function () use($GScriptTimer, $GColors) { $time = $GScriptTimer->get(); if ($time >= 1) { $timeSpent = timeIntervalStr($time); } else { $timeSpent = 'less then a second'; } if (is_callable('beforeShutdown')) { beforeShutdown(); } $timeText = $GColors->getColoredString($timeSpent, 'light_blue'); $doneMsg = " DONE. Time spent: {$timeText} "; $doneText = str_repeat('*', 3) . $doneMsg; echo $GColors->getColoredString("\n{$doneText}\n", 'light_green'); });
/** * Prints the current timer value and stops the timer. * * @param string $ps_name Name of timer * @param string $ps_message Formatting string for display. String may contain placeholders for time (%time) and timer name (%name). [Default is "[%name] %time seconds<br/>\n"] * @param array $pa_option Options include: * decimals = Number of decimal places to display [Default is 6] * * @return void */ static function printAndStop($ps_name, $ps_message = "[%name] %time seconds<br/>\n", $pa_options = null) { print Timer::get($ps_name, $ps_message, $pa_options); return Timer::stop($ps_name); }
</div> </div> <div class="debuginfo break"> <p> <?php foreach($genotypes as $id => $genotype) { echo "<h3>Debug data for genotype nr $id: </h3><p>"; foreach($genotype as $note) { $degreeInfo = $music->getDegreeWithOctaveFromNote($note, MusicScales::Major(), NoteSearchMode::UP); echo $music->getHumanReadableNoteFromDegree($degreeInfo, 'American').', '; } echo '</p>'; } if (defined('DEBUG')) { echo '<div class="debuglog"><pre>'; echo nl2br(file_get_contents(DEBUG.'/log.txt'), true); echo '</pre></div>'; unlink(DEBUG.'/log.txt'); } $mainTimer->stop(); echo '<p>Page generation time: '.$mainTimer->get().'</p>'; ?> </p> </div> </div> </div> </body> </html>
function run_test($all_t) { echo 'Start test ' . $all_t . ' '; $timer = new Timer(1); $servername = "localhost"; $username = "******"; $password = ""; $database = 'randomy'; $looper = 10; // Create connection $conn = mysqli_connect($servername, $username, $password); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } // Create database $sql = "CREATE DATABASE " . $database; if ($conn->query($sql) === TRUE) { $time1 = $timer->get(); echo "Start(pass) " . $time1 . ' '; } else { echo "Error creating database: " . $conn->error . '<br>'; //echo 'Database Exists'; $time1 = $timer->get(); echo "Start(fail) " . $time1 . ' '; } $conn->close(); $time_2 = $time_3 = $time_4 = $time_5 = array(); for ($ff = 1; $ff <= $looper; $ff++) { $mysqli = mysqli_connect($servername, $username, $password, $database) or die("could not connect to mysql"); $time_2[] = $timer->get(); //echo "<br>Db connection established at : " . $timer->get() . "<br \> " ; // Create an sql command structure for creating a table $tableCreate = "CREATE TABLE IF NOT EXISTS test_tbl (\n id int(11) NOT NULL auto_increment ,\n RandomTxt TEXT ,\n RandomTxty TEXT,\n PRIMARY KEY (id)\n ) "; // This line uses the mysqli_query() function to create the table now $queryResult = mysqli_query($mysqli, $tableCreate); $time_3[] = $timer->get(); //echo "Table created at : " . $timer->get() . "<br \> " ; // Create a conditional to see if the query executed successfully or not if ($queryResult === TRUE) { for ($i = 1; $i <= 1000; $i++) { mysqli_query($mysqli, "INSERT INTO Test_tbl (RandomTxt,RandomTxty) VALUES ('abcdefghklmnopqrsst','abcdefghklmnopqrsst')"); } } else { print "<br /><br />No TABLE created. Check"; } $time_4[] = $timer->get(); //echo "Data inserted into the table at : " . $timer->get() . "<br \> " ; $result = mysqli_query($mysqli, 'SELECT * FROM Test_tbl'); $arrayResults = array(); while ($row = $result->fetch_assoc()) { array_push($arrayResults, $row['RandomTxt']); } $time_5[] = $timer->get(); //echo "Data is read from table and inserted into an array at : ". $timer->get() . "" ; //print_r($arrayResults) ; $mysqli->close(); } //drop database //drop database $connt = mysqli_connect($servername, $username, $password); // Check connection if ($connt->connect_error) { die("Connection failed: " . $conn->connect_error); } // Create database $sql = "DROP DATABASE " . $database; if ($connt->query($sql) === TRUE) { $time10 = $timer->get(); echo " End(pass): " . $time10; } else { //echo "Error creating database: " . $conn->error; //echo 'Database Exists'; $time10 = $timer->get(); echo " End(fail) " . $time10; } $connt->close(); ?> <BR> <table class="my_sup_table"> <tbody> <tr> <td> </td> <?php for ($ff = 0; $ff < $looper; $ff++) { ?> <td> Test <?php echo $ff + 1; ?> </td> <?php } ?> </tr> <tr> <td>Connection established</td> <?php for ($ff = 0; $ff < $looper; $ff++) { ?> <td><?php if ($ff > 0) { if (isset($time_5[$ff - 1])) { $first = roundme($time_2[$ff] - $time_5[$ff - 1]); } else { $first = roundme($time_2[$ff] - $time1); } } else { $first = roundme($time_2[$ff] - $time1); } echo $first; ?> </td> <?php } ?> </tr> <tr> <td>Table created</td> <?php for ($ff = 0; $ff < $looper; $ff++) { ?> <td><?php echo roundme($time_3[$ff] - $time_2[$ff]); ?> </td> <?php } ?> </tr> <tr> <td>Records inserted</td> <?php for ($ff = 0; $ff < $looper; $ff++) { ?> <td><?php echo roundme($time_4[$ff] - $time_3[$ff]); ?> </td> <?php } ?> </tr> <tr> <td>Data read</td> <?php for ($ff = 0; $ff < $looper; $ff++) { ?> <td><?php echo roundme($time_5[$ff] - $time_4[$ff]); ?> </td> <?php } ?> </tr> <tr class="orange"> <td> </td> <?php for ($ff = 0; $ff < $looper; $ff++) { ?> <td> <?php echo roundme($first + ($time_3[$ff] - $time_2[$ff]) + ($time_4[$ff] - $time_3[$ff]) + ($time_5[$ff] - $time_4[$ff])); ?> </td> <?php } ?> </tr> </tbody> </table> <br><br> <?php }
function run_test($all_t) { echo 'Start test ' . $all_t . ' '; $timer = new Timer(1); $servername = "localhost"; $username = "******"; $password = ""; $database = 'randomy'; $looper = 15; // Create connection //$conn = mysqli_connect($servername, $username, $password); try { $dbh = new PDO('mysql:host=' . $servername . ';', $username, $password); $stmt = $dbh->query("CREATE DATABASE " . $database); $time1 = $timer->get(); echo "Start(pass) " . $time1 . ' '; $dbh = null; } catch (PDOException $e) { print "Error!: " . $e->getMessage() . "<br/>"; $time1 = $timer->get(); echo "Start(fail) " . $time1 . ' '; die; } $time_2 = $time_3 = $time_4 = $time_5 = array(); for ($ff = 1; $ff <= $looper; $ff++) { //$mysqli = mysqli_connect($servername,$username,$password, $database) ; $mysqli = new PDO('mysql:host=' . $servername . ';dbname=' . $database, $username, $password); $time_2[] = $timer->get(); $tableCreate = "CREATE TABLE IF NOT EXISTS test_tbl (\n id int(11) NOT NULL auto_increment ,\n RandomTxt TEXT ,\n RandomTxty TEXT,\n PRIMARY KEY (id)\n ) "; try { $stmt = $mysqli->query($tableCreate); $time1 = $timer->get(); //echo "table created ".$time1.' '; $time_3[] = $timer->get(); } catch (PDOException $e) { print "Error!: " . $e->getMessage() . "<br/>"; $time_3[] = $timer->get(); echo "unable to create table "; } //echo "Table created at : " . $timer->get() . "<br \> " ; // Create a conditional to see if the query executed successfully or not for ($i = 1; $i <= 1000; $i++) { $mysqli->query("INSERT INTO Test_tbl (RandomTxt,RandomTxty) VALUES ('abcdefghklmnopqrsst','abcdefghklmnopqrsst')"); } $time_4[] = $timer->get(); $arrayResults_data = []; foreach ($mysqli->query('SELECT * from Test_tbl') as $arrayResults) { $arrayResults_data[] = $arrayResults; // print_r($arrayResults); } $time_5[] = $timer->get(); //echo "Data is read from table and inserted into an array at : ". $timer->get() . "" ; //print_r($arrayResults) ; $mysqli = null; } //drop database //drop database //$connt = mysqli_connect($servername, $username, $password); try { $dbh2 = new PDO('mysql:host=' . $servername . ';', $username, $password); $stmt = $dbh2->query("DROP DATABASE " . $database); $time10 = $timer->get(); echo "End(pass) " . $time10 . ' '; $dbh2 = null; } catch (PDOException $e) { print "Error!: " . $e->getMessage() . ""; $time10 = $timer->get(); echo "End(fail) " . $time10 . ' '; die; } ?> <BR> <table class="my_sup_table"> <tbody> <tr> <td> </td> <?php for ($ff = 0; $ff < $looper; $ff++) { ?> <td> Test <?php echo $ff + 1; ?> </td> <?php } ?> </tr> <tr> <td>Connection established</td> <?php for ($ff = 0; $ff < $looper; $ff++) { ?> <td><?php if ($ff > 0) { if (isset($time_5[$ff - 1])) { $first = roundme($time_2[$ff] - $time_5[$ff - 1]); } else { $first = roundme($time_2[$ff] - $time1); } } else { $first = roundme($time_2[$ff] - $time1); } echo $first; ?> </td> <?php } ?> </tr> <tr> <td>Table created</td> <?php for ($ff = 0; $ff < $looper; $ff++) { ?> <td><?php echo roundme($time_3[$ff] - $time_2[$ff]); ?> </td> <?php } ?> </tr> <tr> <td>Records inserted</td> <?php for ($ff = 0; $ff < $looper; $ff++) { ?> <td><?php echo roundme($time_4[$ff] - $time_3[$ff]); ?> </td> <?php } ?> </tr> <tr> <td>Data read</td> <?php for ($ff = 0; $ff < $looper; $ff++) { ?> <td><?php echo roundme($time_5[$ff] - $time_4[$ff]); ?> </td> <?php } ?> </tr> <tr class="orange"> <td> </td> <?php for ($ff = 0; $ff < $looper; $ff++) { ?> <td> <?php echo roundme($first + ($time_3[$ff] - $time_2[$ff]) + ($time_4[$ff] - $time_3[$ff]) + ($time_5[$ff] - $time_4[$ff])); ?> </td> <?php } ?> </tr> </tbody> </table> <br><br> <?php }
$classifiers[$k] = $v[$_POST['set']]; if ($suppressThreshold) { $classifiers[$k]['threshold'] = 0.0; } } } // utwórz obiekty klasyfikatorów, obiekty czasomierzy a nastêpnie klasyfikuj foreach ($classifiers as $k => $v) { $tmpc = new ReflectionClass($k); $classObj[$k] = $tmpc->newInstance($db, $dictionaries, $_POST['set'], false, $v); $time = new Timer(); if (is_null($prepText)) { $time->set('start'); $prepText = $classObj[$k]->doPreparation($_POST['comment']); $time->set('doPreparation'); $prepResult['time'] = '<b>' . $time->format($time->get('doPreparation')) . '</b>'; if ($prepText === false) { break; } } $time->set('start'); $results[$k] = $classObj[$k]->doClassify($prepText, true); $time->set('doClassify'); $times[$k] = $time->format($time->get('doClassify')); } unset($classObj); $prepResult['org'] = $_POST['comment']; ?> <!--<h4>Testowany komentarz</h4> <textarea readonly="true" cols="60" rows="15" name="comment" id="comment" title="Tre¶æ komentarza"> <?php
function logTime($key) { MateApplication::logValue($key, Timer::get()); }