public static function show($id)
 {
     $pokemon = Pokemons::find($id);
     //$joins = Joins::getJoins($id);
     $stats = Stats::getStats($id);
     View::make('Pokemons/:id.html', array('pokemon' => $pokemon, 'stats' => $stats));
 }
Example #2
0
foreach ($files as $file) {
    if (strpos($file, "snapshot") !== false) {
        // fnt is YYYY.mm.dd.HH.ii.ss
        sscanf($file, "snapshot-%d.%d.%d.%d.%d.%d", $y, $m, $d, $h, $i, $s);
        $time = mktime($h, $i, $s, $m, $d, $y);
        if ($time > $ts || $ts == 0) {
            $newfiles[] = $file;
        }
    }
}
print "finding files took: " . (microtime(true) - $start) . " secs\n";
$start = microtime(true);
// count the number of snapshots
$c = count($newfiles);
// get data we are interested in from each snapshot (quarantined/fast/ssl/good)
$bad = $stats->getStats(Stats::BAD);
$fast = $stats->getStats(Stats::FAST);
$ssl = $stats->getStats(Stats::SSL);
$good = $stats->getStats(Stats::GOOD);
//$xAxis = array();
$files = $stats->getDates(X_AXIS_FORMAT);
print "fetching stats took: " . (microtime(true) - $start) . " secs\n";
$start = microtime(true);
for ($j = 0; $j < $c; $j++) {
    $file = PF_DIR . "/" . $newfiles[$j];
    sscanf($newfiles[$j], "snapshot-%d.%d.%d.%d.%d.%d", $y, $m, $d, $h, $i, $s);
    $date = sprintf("%d.%02d.%02d.%02d.%02d.%02d", $y, $m, $d, $h, $i, $s);
    print "date: {$date}\n";
    $db = new DatabaseImpl($file);
    $count = count($db->searchEntries(SEARCH_FIELD_OFFSET | SEARCH_ARRAY, 8, 1));
    $stats->addStats($date, Stats::BAD, $count);
Example #3
0
<?php

/**
 * Stats Example
 * @author Michael Wright	@MichaelW90
 */
// Stats class include
if (!(include_once './Stats.class.php')) {
    die('Error including Stats.class.php');
}
// Instantiate instance of class
$stats = new Stats();
// Store the stats!
foreach ($stats->getStats() as $key => $item) {
    echo '<strong>' . ucwords($key) . ':</strong> ';
    if (is_array($item)) {
        echo '<br />';
        ksort($item);
        foreach ($item as $subkey => $subitem) {
            echo '<strong>- ' . $subkey . ':</strong> ' . $subitem . '<br />';
        }
    } else {
        echo $item . '<br />';
    }
}
Example #4
0
        Event::on('query.started', array($this, 'started'));
        Event::on('query.completed', array($this, 'completed'));
    }
    /** Called when a query has started. */
    public function started($query, $arguments)
    {
        $this->active = array('query' => $query, 'arguments' => $arguments, 'start' => microtime(true));
    }
    /** Called when a query has completed. */
    public function completed($query)
    {
        $active = $this->active;
        $active['end'] = microtime(true);
        $active['duration'] = $active['end'] - $active['start'];
        $this->stats[] = $active;
        $this->active = null;
    }
    /** Returns the collected statistics. */
    public function getStats()
    {
        return $this->stats;
    }
}
$stats = new Stats();
$stats->register();
// Execute some queries
Person::find(10);
Person::objects()->fetch();
// Print collected statistics
print_r($stats->getStats());