コード例 #1
0
ファイル: timestore_read.php プロジェクト: jurviz/development
<?php

/*

  Timestore: dedicated timeseries database written in C by Mike Stirling

  To install timestore:

    git clone http://mikestirling.co.uk/git/timestore.git
    cd timestore
    make
    cd src
    sudo ./timestore -d

  Fetch the admin key:

    cd /var/lib/timestore
    nano adminkey.txt

  Insert admin key below.
*/
// Select 1000 over 5 hours 45ms
// Select 10 over 1 hours 20ms
$timestore_adminkey = "sZ9R_j}5m5mJUv,N{8hhI=ihmuUf.0Q6";
require "timestore_class.php";
$timestore = new Timestore($timestore_adminkey);
$benchstart = microtime(true);
$start = time();
$end = $start + 3600 * 5;
echo $timestore->get_series(308, 0, 1000, $start, $end, null);
echo "Time: " . (microtime(true) - $benchstart) * 1000 . "ms \n";
コード例 #2
0
ファイル: timestore.php プロジェクト: jurviz/development
  Timestore: dedicated timeseries database written in C by Mike Stirling

  To install timestore:

    git clone http://mikestirling.co.uk/git/timestore.git
    cd timestore
    make
    cd src
    sudo ./timestore -d

  Fetch the admin key:

    cd /var/lib/timestore
    nano adminkey.txt

  Insert admin key below.
*/
// 10000 inserts 52s
// 100000 inserts 524s
$timestore_adminkey = "sZ9R_j}5m5mJUv,N{8hhI=ihmuUf.0Q6";
require "timestore_class.php";
$timestore = new Timestore($timestore_adminkey);
$time = time();
$value = 1000;
$timestore->create_node(308, 10);
$start = time();
for ($i = 0; $i < 10000; $i++) {
    $timestore->post_values(308, $time * 1000, array($value), null);
    $time += 10;
}
echo "Time: " . (time() - $start) . "s \n";
コード例 #3
0
ファイル: timestoreredis.php プロジェクト: jurviz/development
<?php

// Implementation of simpified emoncms input processing using timestore by Mike Stirling for disk storage of feed data and redis for temporary storage of last value data.
// Licence: GNU GPL, Author Trystan Lea
error_reporting(E_ALL);
ini_set('display_errors', 'on');
require 'Predis/Autoloader.php';
Predis\Autoloader::register();
$userid = 4;
$timestore_adminkey = "sZ9R_j}5m5mJUv,N{8hhI=ihmuUf.0Q6";
require "timestore/Modules/feed/timestore_class.php";
$timestore = new Timestore($timestore_adminkey);
$redis = new Predis\Client();
$mysqli = new mysqli("localhost", "root", "raspberry", "emoncms");
// Fetch input descriptor
$result = $mysqli->query("SELECT id,nodeid,name,processList,record FROM input WHERE `userid` = '{$userid}'");
$dbinputs = array();
while ($row = $result->fetch_object()) {
    if ($row->nodeid == null) {
        $row->nodeid = 0;
    }
    if (!isset($dbinputs[$row->nodeid])) {
        $dbinputs[$row->nodeid] = array();
    }
    $dbinputs[$row->nodeid][$row->name] = array('id' => $row->id, 'processList' => $row->processList, 'record' => $row->record);
}
echo json_encode($dbinputs);
// Create a stream context that configures the serial port
// And enables canonical input.
$c = stream_context_create(array('dio' => array('data_rate' => 9600, 'data_bits' => 8, 'stop_bits' => 1, 'parity' => 0, 'flow_control' => 0, 'is_canonical' => 1)));
// Are we POSIX or Windows?  POSIX platforms do not have a