/** * Display the charts for the given benchmark/metric * * @param mixed $benchmark */ function DisplayBenchmarkData(&$benchmark, $metric, $loc = null, $title = null) { global $count; global $aggregate; global $url; global $out_data; $bmname = $benchmark['name']; if (isset($loc)) { $bmname .= ".{$loc}"; } $chart_title = ''; if (isset($title)) { $chart_title = "title: \"{$title} (First View)\","; } $tsv = LoadTrendDataTSV($benchmark['name'], 0, $metric, $url, $loc, $annotations, $meta); if (isset($out_data)) { if (!array_key_exists($bmname, $out_data)) { $out_data[$bmname] = array(); } $out_data[$bmname][$metric] = array(); $out_data[$bmname][$metric]['FV'] = TSVEncode($tsv); foreach ($out_data[$bmname][$metric]['FV'] as $index => &$entry) { if (is_array($entry) && array_key_exists('time', $entry)) { if (array_key_exists($entry['time'], $meta)) { $entry['tests'] = array(); foreach ($meta[$entry['time']] as $index => $value) { if (is_array($value) && array_key_exists('label', $value) && array_key_exists('test', $value)) { $entry['tests'][$value['label']] = $value['test']; } } } } } } if (!isset($out_data) && isset($tsv) && strlen($tsv)) { $count++; $id = "g{$count}"; echo "<div class=\"chart-container\"><div id=\"{$id}\" class=\"benchmark-chart\"></div><div id=\"{$id}_legend\" class=\"benchmark-legend\"></div></div><br>\n"; echo "<script type=\"text/javascript\">\n var {$id}meta = " . json_encode($meta) . ";\n {$id} = new Dygraph(\n document.getElementById(\"{$id}\"),\n \"" . str_replace("\t", '\\t', str_replace("\n", '\\n', $tsv)) . "\",\n {drawPoints: true,\n rollPeriod: 1,\n showRoller: true,\n labelsSeparateLines: true,\n colors: ['#ed2d2e', '#008c47', '#1859a9', '#662c91', '#f37d22', '#a11d20', '#b33893', '#010101'],\n labelsDiv: document.getElementById('{$id}_legend'),\n pointClickCallback: function(e, p) {SelectedPoint({$id}meta, p.xval, false);},\n {$chart_title}\n legend: \"always\"}\n );"; if (isset($annotations) && count($annotations)) { echo "{$id}.setAnnotations(" . json_encode($annotations) . ");\n"; } echo "</script>\n"; } if (!array_key_exists('fvonly', $benchmark) || !$benchmark['fvonly']) { if (isset($title)) { $chart_title = "title: \"{$title} (Repeat View)\","; } $tsv = LoadTrendDataTSV($benchmark['name'], 1, $metric, $url, $loc, $annotations, $meta); if (isset($out_data)) { $out_data[$bmname][$metric]['RV'] = TSVEncode($tsv); foreach ($out_data[$bmname][$metric]['RV'] as $index => &$entry) { if (is_array($entry) && array_key_exists('time', $entry)) { if (array_key_exists($entry['time'], $meta)) { $entry['tests'] = array(); foreach ($meta[$entry['time']] as $index => $value) { if (is_array($value) && array_key_exists('label', $value) && array_key_exists('test', $value)) { $entry['tests'][$value['label']] = $value['test']; } } } } } } if (!isset($out_data) && isset($tsv) && strlen($tsv)) { $count++; $id = "g{$count}"; echo "<br><div class=\"chart-container\"><div id=\"{$id}\" class=\"benchmark-chart\"></div><div id=\"{$id}_legend\" class=\"benchmark-legend\"></div></div>\n"; echo "<script type=\"text/javascript\">\n var {$id}meta = " . json_encode($meta) . ";\n {$id} = new Dygraph(\n document.getElementById(\"{$id}\"),\n \"" . str_replace("\t", '\\t', str_replace("\n", '\\n', $tsv)) . "\",\n {drawPoints: true,\n rollPeriod: 1,\n showRoller: true,\n labelsSeparateLines: true,\n colors: ['#ed2d2e', '#008c47', '#1859a9', '#662c91', '#f37d22', '#a11d20', '#b33893', '#010101'],\n labelsDiv: document.getElementById('{$id}_legend'),\n pointClickCallback: function(e, p) {SelectedPoint({$id}meta, p.xval, true);},\n {$chart_title}\n legend: \"always\"}\n );"; if (isset($annotations) && count($annotations)) { echo "{$id}.setAnnotations(" . json_encode($annotations) . ");\n"; } echo "</script>\n"; } } }
/** * Display the charts for the given benchmark * * @param mixed $benchmark */ function DisplayBenchmarkData(&$benchmark, $loc = null, $title = null) { global $count; global $aggregate; global $out_data; global $INCLUDE_ERROR_BARS; $label = 'Speed Index (First View)'; $chart_title = ''; if (isset($title)) { $chart_title = "title: \"{$title} (First View)\","; } $bmname = $benchmark['name']; if (isset($loc)) { $bmname .= ".{$loc}"; } $errorBars = $INCLUDE_ERROR_BARS && $aggregate == 'median' ? 'customBars: true,' : ''; $tsv = LoadDataTSV($benchmark['name'], 0, 'SpeedIndex', $aggregate, $loc, $annotations); $metric = 'SpeedIndex'; if (!isset($tsv) || !strlen($tsv)) { $label = 'Time to onload (First View)'; $tsv = LoadDataTSV($benchmark['name'], 0, 'docTime', $aggregate, $loc, $annotations); $metric = 'docTime'; } if ($aggregate == 'count') { $label = 'Successful Tests (First View)'; } if (isset($out_data)) { $out_data[$bmname] = array(); $out_data[$bmname][$metric] = array(); $out_data[$bmname][$metric]['FV'] = TSVEncode($tsv); } if (!isset($out_data) && isset($tsv) && strlen($tsv)) { $count++; $id = "g{$count}"; echo "<div class=\"chart-container\"><div id=\"{$id}\" class=\"benchmark-chart\"></div><div id=\"{$id}_legend\" class=\"benchmark-legend\"></div></div>\n"; echo "<script type=\"text/javascript\">\r\n {$id} = new Dygraph(\r\n document.getElementById(\"{$id}\"),\r\n \"" . str_replace("\t", '\\t', str_replace("\n", '\\n', $tsv)) . "\",\r\n {drawPoints: true,\r\n rollPeriod: 1,\r\n showRoller: true,\r\n labelsSeparateLines: true,\r\n colors: ['#ed2d2e', '#008c47', '#1859a9', '#662c91', '#f37d22', '#a11d20', '#b33893', '#010101'],\r\n {$chart_title}\r\n {$errorBars}\r\n labelsDiv: document.getElementById('{$id}_legend'),\r\n pointClickCallback: function(e, p) {SelectedPoint(\"{$benchmark['name']}\", \"{$metric}\", p.name, p.xval, false);},\r\n legend: \"always\",\r\n xlabel: \"Date\",\r\n ylabel: \"{$label}\"}\r\n );\n"; if (isset($annotations) && count($annotations)) { echo "{$id}.setAnnotations(" . json_encode($annotations) . ");\n"; } echo "</script>\n"; } if (!array_key_exists('fvonly', $benchmark) || !$benchmark['fvonly']) { $label = 'Speed Index (Repeat View)'; if (isset($title)) { $chart_title = "title: \"{$title} (Repeat View)\","; } $tsv = LoadDataTSV($benchmark['name'], 1, 'SpeedIndex', $aggregate, $loc, $annotations); $metric = 'SpeedIndex'; if (!isset($tsv) || !strlen($tsv)) { $label = 'Time to onload (Repeat View)'; $tsv = LoadDataTSV($benchmark['name'], 1, 'docTime', $aggregate, $loc, $annotations); $metric = 'docTime'; } if ($aggregate == 'count') { $label = 'Successful Tests (Repeat View)'; } if (isset($out_data)) { $out_data[$bmname][$metric]['RV'] = TSVEncode($tsv); } if (!isset($out_data) && isset($tsv) && strlen($tsv)) { $count++; $id = "g{$count}"; echo "<div class=\"chart-container\"><div id=\"{$id}\" class=\"benchmark-chart\"></div><div id=\"{$id}_legend\" class=\"benchmark-legend\"></div></div>\n"; echo "<script type=\"text/javascript\">\r\n {$id} = new Dygraph(\r\n document.getElementById(\"{$id}\"),\r\n \"" . str_replace("\t", '\\t', str_replace("\n", '\\n', $tsv)) . "\",\r\n {drawPoints: true,\r\n rollPeriod: 1,\r\n showRoller: true,\r\n labelsSeparateLines: true,\r\n colors: ['#ed2d2e', '#008c47', '#1859a9', '#662c91', '#f37d22', '#a11d20', '#b33893', '#010101'],\r\n {$chart_title}\r\n {$errorBars}\r\n labelsDiv: document.getElementById('{$id}_legend'),\r\n pointClickCallback: function(e, p) {SelectedPoint(\"{$benchmark['name']}\", \"{$metric}\", p.name, p.xval, true);},\r\n legend: \"always\",\r\n xlabel: \"Date\",\r\n ylabel: \"{$label}\"}\r\n );"; if (isset($annotations) && count($annotations)) { echo "{$id}.setAnnotations(" . json_encode($annotations) . ");\n"; } echo "</script>\n"; } } }