} else { $file = __DIR__ . '/libs/' . $theme . '/make_graph.php'; if (is_readable($file)) { require $file; } else { require __DIR__ . '/libs/make_graph.php'; } } // RPS Benchmark list($chart_rpm, $div_rpm) = make_graph('rps', 'Throughput', 'requests per second'); // Memory Benchmark list($chart_mem, $div_mem) = make_graph('memory', 'Memory', 'peak memory (MB)'); // Exec Time Benchmark list($chart_time, $div_time) = make_graph('time', 'Exec Time', 'ms'); // Included Files list($chart_file, $div_file) = make_graph('file', 'Included Files', 'count'); ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>PHP Framework Benchmark</title> <script src="https://www.google.com/jsapi"></script> <script> <?php echo $chart_rpm, $chart_mem, $chart_time, $chart_file; ?> </script> </head> <body> <h1>PHP Framework Benchmark</h1>
if (date('H') >= $graphset['stop']) { exit; } if ((int) date('i') % $interval != 0) { exit; } $blackbox = new Blackbox(); $blackbox->process_modules(); ### Render graphs $query = "\n\tselect * from blackboxelements\n\twhere type='g'\n\torder by panetag,position\n"; $params = array('id_view' => 1); $result = $db->query($query, $params) or codeerror('DB error', __FILE__, __LINE__); while ($row = $db->fetch_row($result)) { $id_element = $row['id_element']; $settings = unserialize($row['settings']); make_graph($id_element, $settings); } //all done print $profiler->dump(); exit; //MAKE_GRAPH function make_graph($id_element, $settings) { global $blackbox, $graphset; $day = date("Y-m-d"); //to match our axis to the available data //fish out once per minute datetimes for each module, and hash them //to handle multiple points per minute, for now first one rules //missing samples use NULL $hash = array(); foreach ($blackbox->modules as $mod => $module) {
<?php $data = unserialize(urldecode(stripslashes($_GET['data']))); if (isset($_GET['is_multi'])) { if ($_GET['is_multi'] == 'true') { make_graph_multi_line(urldecode($_GET['title']), $data['min'], $data['avg'], $data['max'], $_GET['is_bar_graph']); } } else { make_graph(urldecode($_GET['title']), $data, $_GET['is_bar_graph'], $_GET['colour']); } function make_graph($title, $data, $is_bar_graph, $colour) { include 'phpgraphlib.php'; $graph = new PHPGraphLib(780, 300); $graph->addData($data); if ($is_bar_graph == 'true') { $graph->setBars(true); $graph->setLine(false); $graph->setBarColor($colour); } else { $graph->setBars(false); $graph->setLine(true); $graph->setLineColor($colour); $graph->setDataPoints(true); $graph->setDataPointSize(4); $graph->setDataPointColor($colour); } $graph->setTitle($title); $graph->setTitleColor("88,89,91"); $graph->setXValuesVertical(true); $graph->createGraph();
$ft = (int) fgets($f); $du = (double) fgets($f); $ul = (double) fgets($f); $dl = (double) fgets($f); return array($ft, $du, $ul, $dl); } if ($argc != 2) { die("usage: ssim.php infile\n"); } $input = parse_input_file($argv[1]); foreach ($input->policy as $p) { $datafile = fopen($input->name . "_{$p}.dat", "w"); if (!file_exists($p)) { die("no policy file '{$p}'\n"); } foreach ($input->host_life_mean as $hlm) { $cmd = "ssim --policy {$p} --host_life_mean {$hlm} --connect_interval {$input->connect_interval} --mean_xfer_rate {$input->mean_xfer_rate} --file_size {$input->file_size} > /dev/null"; echo "{$cmd}\n"; system($cmd); list($ft, $du, $ub, $db) = parse_output_file("summary.txt"); $hlmd = $hlm / 86400; $du_rel = $du / $input->file_size; fprintf($datafile, "{$hlmd} {$ft} {$du_rel} {$ub} {$db}\n"); } fclose($datafile); } make_graph($input, "ft", "Fault tolerance", 2); make_graph($input, "du", "Relative disk usage", 3); make_graph($input, "ub", "Upload bandwidth (Mbps)", 4); make_graph($input, "db", "Download bandwidth (Mbps)", 5);
// In case the user defines his own Raspberry data graph // In case the user defines his own Raspberry data graph case "raspi": $log->lwrite("Starting raspi specific graphs, type: " . $graphType . ", period: " . $graphPeriod); if (!make_graph($graphType, $graphPeriod, $graphSensors)) { $appmsg .= "user error. "; } else { $appmsg .= "Success generate_graphs\n"; $ret = 1; } break; // In case the user defines his own energy graph // In case the user defines his own energy graph case "energy": $log->lwrite("Starting energy specific graphs, type: " . $graphType . ", period: " . $graphPeriod); if (!make_graph($graphType, $graphPeriod, $graphSensors)) { $appmsg .= "user error. "; } else { $appmsg .= "Success generate_graphs\n"; $ret = 1; } break; default: $appmsg .= ", action: " . $graphAction; $apperr .= ", graph: " . $graphAction . ", command not recognized\n"; $ret = -1; } // Test the return values for the several commands // if ($ret >= 0) { $send = array('tcnt' => $ret, 'status' => 'OK', 'result' => $appmsg, 'error' => $apperr);