Summary
Description: Unnamed repository; edit this file to name it for gitweb.
Last Change: Mon 8/30/10 20:43
Recent Commits
>
--git a/CHANGE-LOG b/CHANGE-LOG
index 8f87a13..97553aa 100644
--- a/CHANGE-LOG
+++ b/CHANGE-LOG
@@ -9,7 +9,8 @@ Phoronix Test Suite
- Support multiple possible paths in "PossiblePaths" in test profiles, with each path delimited by a colon
- Support if binary is named php5 instead of php
- Add IgnoreFirstRun argument for test profiles
-- Add support for a test profile to have a downloads.xml file inside their resources folder that contains all of the files that need to be downloaded. Phoronix Test Suite then handles the downloading internally as well as verifying the MD5 sums, downloading from a random URL if multiple URLs are specified, etc. Some other features will come about soon for those using downloads.xml for acquiring all needed files.
+- Add support for a test profile to have a downloads.xml file inside their resources folder that contains all of the files that need to be downloaded. Phoronix Test Suite then handles the downloading internally as well as verifying the MD5 sums, downloading from a random URL if multiple URLs are specified, etc. Some other features will come about soon for those using downloads.xml for acquiring all needed files
+- Drop bcdiv/bcmath dependency for pts_Graph, switch to internal function for trimming doubles
Phoronix Test Suite 0.4.0
April 24, 2008
diff --git a/pts-core/objects/pts_BarGraph.php b/pts-core/objects/pts_BarGraph.php
index abced37..a7d3182 100644
--- a/pts-core/objects/pts_BarGraph.php
+++ b/pts-core/objects/pts_BarGraph.php
@@ -63,7 +63,7 @@ class pts_BarGraph extends pts_CustomGraph
$font_size = $this->graph_font_size_bars;
- while($this->return_ttf_string_width(bcdiv($this->graph_maximum_value, 1, 3), $this->graph_font, $font_size) > ($bar_width - 6))
+ while($this->return_ttf_string_width(trim_double($this->graph_maximum_value, 3), $this->graph_font, $font_size) > ($bar_width - 6))
$font_size -= 0.5;
for($i_o = 0; $i_o < $bar_count; $i_o++)
@@ -98,7 +98,7 @@ class pts_BarGraph extends pts_CustomGraph
imagerectangle($this->graph_image, $px_bound_left + $size_diff_left, $value_plot_top - 1, $px_bound_right - $size_diff_right, $this->graph_top_end - 1, $this->graph_color_body_light);
imagefilledrectangle($this->graph_image, $px_bound_left + $size_diff_left + 1, $value_plot_top, $px_bound_right - $size_diff_right - 1, $this->graph_top_end - 1, $paint_color);
- $value = bcdiv($value, 1, 2);
+ $value = trim_double($value, 2);
if($graph_size > 20)
$this->gd_write_text_center($this->graph_data[$i_o][$i], $font_size, $this->graph_color_body_text, $px_bound_left + (($px_bound_right - $px_bound_left) / 2), $value_plot_top + 3);
diff --git a/pts-core/objects/pts_Graph.php b/pts-core/objects/pts_Graph.php
index 030b306..9fda9aa 100644
--- a/pts-core/objects/pts_Graph.php
+++ b/pts-core/objects/pts_Graph.php
@@ -125,7 +125,7 @@ class pts_Graph
{
for($i = 0; $i < count($data_array); $i++)
if(is_float($data_array[$i]))
- $data_array[$i] = bcdiv($data_array[$i], 1, 2);
+ $data_array[$i] = trim_double($data_array[$i], 2);
array_push($this->graph_data, $data_array);
array_push($this->graph_data_title, $data_title);
@@ -365,7 +365,7 @@ class pts_Graph
imageline($this->graph_image, $y, $px_from_top, $y += ($this->graph_left_end - $y) - 1, $px_from_top, $this->graph_color_body_light);
}
- $display_value += bcdiv($this->graph_maximum_value / $this->graph_attr_marks, 1, 2);
+ $display_value += trim_double($this->graph_maximum_value / $this->graph_attr_marks, 2);
}
}
public function renderGraph()
@@ -434,6 +434,30 @@ class pts_Graph
{
$this->graph_output = $file;
}
+ protected function trim_double($double, $accuracy = 2)
+ {
+ $return = explode(".", $double);
+
+ if(count($return) == 1)
+ $return[1] = "00";
+
+ if(count($return) == 2)
+ {
+ $strlen = strlen($return[1]);
+
+ if($strlen > $accuracy)
+ $return[1] = substr($return[1], 0, $accuracy);
+ else if($strlen < $accuracy)
+ for($i = $strlen; $i < $accuracy; $i++)
+ $return[1] .= "0";
+
+ $return = $return[0] . "." . $return[1];
+ }
+ else
+ $return = $return[0];
+
+ return $return;
+ }
}
Copyright © 2010 by Phoronix Media