Revision: 210
http://polepos.svn.sourceforge.net/polepos/?rev=210&view=rev
Author: carlrosenberger
Date: 2011-07-18 16:51:14 +0000 (Mon, 18 Jul 2011)
Log Message:
-----------
cr + frm: Support for linear graphs. New variable LOGARITHMIC in Settings to get back old behaviour.
Modified Paths:
--------------
trunk/polepos/src/org/polepos/Settings.java
trunk/polepos/src/org/polepos/reporters/CustomBarPDFReporter.java
trunk/polepos/src/org/polepos/reporters/CustomBarRendererBase.java
trunk/polepos/src/org/polepos/reporters/Graph.java
Added Paths:
-----------
trunk/polepos/src/org/polepos/reporters/FixedTimeCustomBarRendererBase.java
trunk/polepos/src/org/polepos/reporters/LinearFixedTimeCustomBarRenderer.java
trunk/polepos/src/org/polepos/reporters/LinearTimedLapsCustomBarRenderer.java
trunk/polepos/src/org/polepos/reporters/LogarithmicFixedTimeCustomBarRenderer.java
trunk/polepos/src/org/polepos/reporters/LogarithmicTimedLapsCustomBarRenderer.java
trunk/polepos/src/org/polepos/reporters/TimedLapsCustomBarRendererBase.java
Removed Paths:
-------------
trunk/polepos/src/org/polepos/reporters/FixedTimeCustomBarRenderer.java
trunk/polepos/src/org/polepos/reporters/TimedLapsCustomBarRenderer.java
Modified: trunk/polepos/src/org/polepos/Settings.java
===================================================================
--- trunk/polepos/src/org/polepos/Settings.java 2011-07-15 16:00:32 UTC (rev 209)
+++ trunk/polepos/src/org/polepos/Settings.java 2011-07-18 16:51:14 UTC (rev 210)
@@ -24,8 +24,10 @@
private static boolean DEBUG = false;
- private static boolean CONCURRENCY = false;
+ private static boolean CONCURRENCY = true;
+ public static boolean LOGARITHMIC = false;
+
public static final String CIRCUIT = isDebug() ? "settings/DebugCircuits.properties" : "settings/Circuits.properties" ;
public static final String JDBC = "settings/Jdbc.properties";
Modified: trunk/polepos/src/org/polepos/reporters/CustomBarPDFReporter.java
===================================================================
--- trunk/polepos/src/org/polepos/reporters/CustomBarPDFReporter.java 2011-07-15 16:00:32 UTC (rev 209)
+++ trunk/polepos/src/org/polepos/reporters/CustomBarPDFReporter.java 2011-07-18 16:51:14 UTC (rev 210)
@@ -22,6 +22,8 @@
import java.awt.*;
+import org.polepos.*;
+
import com.db4o.*;
import com.db4o.config.*;
import com.db4o.ta.*;
@@ -42,7 +44,7 @@
cfg.common().add(new TransparentPersistenceSupport());
// EmbeddedObjectContainer db = Db4oEmbedded.openFile(cfg, "ClientServerGraph.db4o");
- EmbeddedObjectContainer db = Db4oEmbedded.openFile(cfg, "EmbeddedGraph.db4o");
+ EmbeddedObjectContainer db = Db4oEmbedded.openFile(cfg, "graph.db4o");
// EmbeddedObjectContainer db = Db4oEmbedded.openFile(cfg, "ConcurrentGraph.db4o");
PersistentGraphs pg = db.query(PersistentGraphs.class).iterator().next();
@@ -74,18 +76,30 @@
PdfTemplate tp = cb.createTemplate(chartWidth(), chartHeight());
Graphics2D graphics = tp.createGraphics(chartWidth(), chartHeight(), new DefaultFontMapper());
- int height = new TimedLapsCustomBarRenderer(graph).render(graphics);
+ int height = newRenderer(graph).render(graphics);
tp = cb.createTemplate(chartWidth(), height);
graphics = tp.createGraphics(chartWidth(), height, new DefaultFontMapper());
- (graph.circuit().isFixedTime() ? new FixedTimeCustomBarRenderer(graph) : new TimedLapsCustomBarRenderer(graph)).render(graphics);
+ newRenderer(graph).render(graphics);
graphics.dispose();
return new ImgTemplate(tp);
}
-
+ private CustomBarRendererBase newRenderer(Graph graph){
+ if(graph.circuit().isFixedTime()){
+ if(Settings.LOGARITHMIC){
+ return new LogarithmicFixedTimeCustomBarRenderer(graph);
+ }
+ return new LinearFixedTimeCustomBarRenderer(graph);
+ }
+ if(Settings.LOGARITHMIC){
+ return new LogarithmicTimedLapsCustomBarRenderer(graph);
+ }
+ return new LinearTimedLapsCustomBarRenderer(graph);
+ }
+
@Override
protected void renderTableAndGraph(int type, Graph graph, String unitsLegend) throws BadElementException {
}
Modified: trunk/polepos/src/org/polepos/reporters/CustomBarRendererBase.java
===================================================================
--- trunk/polepos/src/org/polepos/reporters/CustomBarRendererBase.java 2011-07-15 16:00:32 UTC (rev 209)
+++ trunk/polepos/src/org/polepos/reporters/CustomBarRendererBase.java 2011-07-18 16:51:14 UTC (rev 210)
@@ -42,12 +42,16 @@
}
protected static class TurnData {
+
public TurnData(TurnSetup turn, long best) {
this.turn = turn;
this.best = best;
}
+
TurnSetup turn;
+
long best;
+
public List<TeamData> teams = new ArrayList<TeamData>();
}
@@ -91,20 +95,32 @@
EmbeddedObjectContainer db = Db4oEmbedded.openFile("graph.db4o");
- Graph graph = db.query(Graph.class).iterator().next();
+ int circuitNo = 5;
+ ObjectSet<Graph> result = db.query(Graph.class);
+ // Graph graph = result.iterator().next();
+ Graph graph = result.get(circuitNo);
+
+
db.activate(graph, Integer.MAX_VALUE);
db.close();
- final CustomBarRendererBase renderer = (graph.circuit().isFixedTime() ? new FixedTimeCustomBarRenderer(graph) : new TimedLapsCustomBarRenderer(graph));
- JFrame w = new JFrame("Polepos preview") {
+ // final CustomBarRendererBase renderer = (graph.circuit().isFixedTime() ? new FixedTimeCustomBarRenderer(graph) : new LogarithmicTimedLapsCustomBarRenderer(graph));
+ final CustomBarRendererBase renderer = (graph.circuit().isFixedTime() ? new LinearFixedTimeCustomBarRenderer(graph) : new LinearTimedLapsCustomBarRenderer(graph));
+
+ JFrame w = new JFrame("Polepos preview");
+ JPanel contentPane = new JPanel()
+ {
private static final long serialVersionUID = 1L;
@Override
public void paint(Graphics g) {
super.paint(g);
renderer.render(g);
}
+
};
+ w.setContentPane(contentPane);
+ contentPane.setBackground(Color.WHITE);
w.setSize(522, 600);
w.setVisible(true);
@@ -119,12 +135,16 @@
return graphData().maxTeamNameWidth+1;
}
- double maxBarWidth() {
- return graphics.getClipBounds().getWidth() - barX() - textWidth("10000x")/2;
+ double maxBarWidthWithLegend() {
+ return maxBarWidth()- textWidth("10000x")/2;
}
+
+ double maxBarWidth(){
+ return graphics.getClipBounds().getWidth() - barX();
+ }
protected double widthPerOrderOfMagnitude() {
- return maxBarWidth() / graphData().maxMagnitude;
+ return maxBarWidthWithLegend() / graphData().maxMagnitude;
}
public int render(Graphics graphics) {
@@ -153,7 +173,10 @@
graphics.setColor(Color.BLACK);
graphics.drawLine(axisX, 0, axisX, y);
graphics.drawLine(axisX, y, (int) graphics.getClipBounds().getWidth(), y);
-
+ return renderXLegend(graphics, y, axisX);
+ }
+
+ protected int renderXLegend(Graphics graphics, int y, int axisX) {
for(int i=0;i<=graphData().maxMagnitude;i++) {
int x = (int) (i * widthPerOrderOfMagnitude()) + axisX;
@@ -175,10 +198,7 @@
graphics.drawString(legend, (int)(x-textWidth(legend)/2.), (int)(y+graphData().markerHeight+textHeight(legend)));
}
- y += stride()*2;
-
- return y;
-
+ return (int) (y + stride()*2);
}
protected abstract boolean doDrawXAxisMarker(int i);
@@ -212,15 +232,13 @@
graphics.fillRect((int)barX(), (int) y, barWidth, (int) graphData().barHeight);
- String magnitude = magnitudeBarLegend(teamData);
-
graphics.setColor(Color.BLACK);
- graphics.drawString(magnitude, (int)(barX()+barWidth+graphData().paddingX), textY);
+ graphics.drawString(legendOnRightOfBar(teamData), (int)(barX()+barWidth+graphData().paddingX), textY);
if (teamData.val > 0) {
- String absolute = teamData.val+ taskLegend();
+ String legendInsideBar = legendInsideBar(teamData);
graphics.setColor(Color.WHITE);
- graphics.drawString(absolute, (int)(barX()+barWidth-textWidth(absolute)-graphData().paddingX), textY);
+ graphics.drawString(legendInsideBar, (int)(barX()+barWidth-textWidth(legendInsideBar)-graphData().paddingX), textY);
}
y += stride();
@@ -229,17 +247,17 @@
}
- protected abstract String magnitudeBarLegend(TeamData teamData);
+ protected abstract String legendInsideBar(TeamData teamData);
- protected abstract String taskLegend();
+ protected abstract String legendOnRightOfBar(TeamData teamData);
protected abstract int barWidth(TeamData teamData);
- private double textWidth(String string) {
+ protected double textWidth(String string) {
return textBounds(graphics, string, graphics.getFont()).getWidth();
}
- private double textHeight(String string) {
+ protected double textHeight(String string) {
return textBounds(graphics, string, graphics.getFont()).getHeight();
}
Deleted: trunk/polepos/src/org/polepos/reporters/FixedTimeCustomBarRenderer.java
===================================================================
--- trunk/polepos/src/org/polepos/reporters/FixedTimeCustomBarRenderer.java 2011-07-15 16:00:32 UTC (rev 209)
+++ trunk/polepos/src/org/polepos/reporters/FixedTimeCustomBarRenderer.java 2011-07-18 16:51:14 UTC (rev 210)
@@ -1,119 +0,0 @@
-/*
-This file is part of the PolePosition database benchmark
-http://www.polepos.org
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public
-License along with this program; if not, write to the Free
-Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
-MA 02111-1307, USA. */
-
-
-package org.polepos.reporters;
-
-import java.util.*;
-
-import org.polepos.framework.*;
-import org.polepos.reporters.CustomBarRendererBase.*;
-
-public class FixedTimeCustomBarRenderer extends CustomBarRendererBase {
-
- private static final int BEST_MAGNITUDE = 5;
-
- public FixedTimeCustomBarRenderer(Graph graph) {
- super(graph);
- }
-
- @Override
- protected List<TurnData> prepareTurnsData(final Graph graph) {
- List<TurnData> runs = new ArrayList<TurnData>();
-
- final List<TurnSetup> setups = graph.setups();
- List<TeamCar> teamCars = graph.teamCars();
-
- for (final TurnSetup setup : setups) {
-
- TurnData turnData = new TurnData(setup, 0);
- long best = 0;
- for (TeamCar teamCar : teamCars) {
- long iterations = graph.iterationsFor(teamCar, setup);
- TeamData teamData = new TeamData(teamCar, 0, iterations);
- if (iterations != 0 && iterations > best) {
- best = iterations;
- }
- turnData.teams.add(teamData);
- }
- turnData.best = best;
-
- for (TeamData teamData : turnData.teams) {
- teamData.orderOfMagnitude = (double)turnData.best / (teamData.val == 0 ? 1 : teamData.val) ;
- }
-
- Collections.sort(turnData.teams, new Comparator<TeamData>() {
-
- @Override
- public int compare(TeamData team1, TeamData team2) {
- long iterations1 = graph.iterationsFor(team1.teamCar, setup);
- long iterations2 = graph.iterationsFor(team2.teamCar, setup);
-
- if (iterations1 < iterations2) {
- return 1;
- }
- if (iterations1 > iterations2) {
- return -1;
- }
- return 0;
- }
- });
-
- runs.add(turnData);
- }
- return runs;
- }
-
- @Override
- protected int barWidth(TeamData teamData) {
- return (int)((BEST_MAGNITUDE - barUnits(teamData.orderOfMagnitude)) * widthPerOrderOfMagnitude());
- }
-
- @Override
- protected String taskLegend() {
- return " iterations";
- }
-
- @Override
- protected String magnitudeBarLegend(TeamData teamData) {
-
- double orderOfMagnitude = teamData.orderOfMagnitude;
- if(orderOfMagnitude == 1){
- return "";
- }
- return String.format("1/%.1fx", orderOfMagnitude);
- }
-
- @Override
- protected String magnitudeAxisLegend(int i) {
- if(i == BEST_MAGNITUDE - 1){
- return "best";
- }
- if(i > BEST_MAGNITUDE - 1){
- return "";
- }
- return String.format("1/%.0fx", Math.pow(10, BEST_MAGNITUDE - 1 - i));
- }
-
- @Override
- protected boolean doDrawXAxisMarker(int i) {
- return i < BEST_MAGNITUDE;
- }
-
-}
Added: trunk/polepos/src/org/polepos/reporters/FixedTimeCustomBarRendererBase.java
===================================================================
--- trunk/polepos/src/org/polepos/reporters/FixedTimeCustomBarRendererBase.java (rev 0)
+++ trunk/polepos/src/org/polepos/reporters/FixedTimeCustomBarRendererBase.java 2011-07-18 16:51:14 UTC (rev 210)
@@ -0,0 +1,86 @@
+/*
+This file is part of the PolePosition database benchmark
+http://www.polepos.org
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public
+License along with this program; if not, write to the Free
+Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+MA 02111-1307, USA. */
+
+package org.polepos.reporters;
+
+import java.util.*;
+
+import org.polepos.framework.*;
+
+public abstract class FixedTimeCustomBarRendererBase extends CustomBarRendererBase {
+
+ public FixedTimeCustomBarRendererBase(Graph graph) {
+ super(graph);
+ }
+
+ @Override
+ protected List<TurnData> prepareTurnsData(final Graph graph) {
+
+ graph.best = 0;
+
+ List<TurnData> runs = new ArrayList<TurnData>();
+
+ final List<TurnSetup> setups = graph.setups();
+ List<TeamCar> teamCars = graph.teamCars();
+
+ for (final TurnSetup setup : setups) {
+
+ TurnData turnData = new TurnData(setup, 0);
+ long best = 0;
+ for (TeamCar teamCar : teamCars) {
+ long iterations = graph.iterationsFor(teamCar, setup);
+ TeamData teamData = new TeamData(teamCar, 0, iterations);
+ if (iterations != 0 && iterations > best) {
+ best = iterations;
+ }
+ if(iterations != 0 && iterations > graph.best){
+ graph.best = iterations;
+ }
+ turnData.teams.add(teamData);
+ }
+ turnData.best = best;
+
+ for (TeamData teamData : turnData.teams) {
+ teamData.orderOfMagnitude = (double)turnData.best / (teamData.val == 0 ? 1 : teamData.val) ;
+ }
+
+ Collections.sort(turnData.teams, new Comparator<TeamData>() {
+
+ @Override
+ public int compare(TeamData team1, TeamData team2) {
+ long iterations1 = graph.iterationsFor(team1.teamCar, setup);
+ long iterations2 = graph.iterationsFor(team2.teamCar, setup);
+
+ if (iterations1 < iterations2) {
+ return 1;
+ }
+ if (iterations1 > iterations2) {
+ return -1;
+ }
+ return 0;
+ }
+ });
+
+ runs.add(turnData);
+ }
+ return runs;
+ }
+
+
+}
\ No newline at end of file
Property changes on: trunk/polepos/src/org/polepos/reporters/FixedTimeCustomBarRendererBase.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/polepos/src/org/polepos/reporters/Graph.java
===================================================================
--- trunk/polepos/src/org/polepos/reporters/Graph.java 2011-07-15 16:00:32 UTC (rev 209)
+++ trunk/polepos/src/org/polepos/reporters/Graph.java 2011-07-18 16:51:14 UTC (rev 210)
@@ -33,6 +33,9 @@
private final Circuit circuit;
private final Lap lap;
+ public long best;
+ public long worst;
+
public Graph(Result result){
teamCars= new ArrayList<TeamCar>();
setups=new ArrayList<TurnSetup>();
Added: trunk/polepos/src/org/polepos/reporters/LinearFixedTimeCustomBarRenderer.java
===================================================================
--- trunk/polepos/src/org/polepos/reporters/LinearFixedTimeCustomBarRenderer.java (rev 0)
+++ trunk/polepos/src/org/polepos/reporters/LinearFixedTimeCustomBarRenderer.java 2011-07-18 16:51:14 UTC (rev 210)
@@ -0,0 +1,79 @@
+/*
+This file is part of the PolePosition database benchmark
+http://www.polepos.org
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public
+License along with this program; if not, write to the Free
+Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+MA 02111-1307, USA. */
+
+
+package org.polepos.reporters;
+
+import java.awt.*;
+
+public class LinearFixedTimeCustomBarRenderer extends FixedTimeCustomBarRendererBase {
+
+ private static final int BEST_MAGNITUDE = 5;
+
+ public LinearFixedTimeCustomBarRenderer(Graph graph) {
+ super(graph);
+ }
+
+ @Override
+ protected int barWidth(TeamData teamData) {
+ return (int) (((double)teamData.val / (double)graph.best) * (double)maxBarWidthWithLegend() );
+ }
+
+ @Override
+ protected String legendOnRightOfBar(TeamData teamData) {
+ return "";
+ // return " iterations";
+ }
+
+ @Override
+ protected String magnitudeAxisLegend(int i) {
+ if(i == BEST_MAGNITUDE - 1){
+ return "best";
+ }
+ if(i > BEST_MAGNITUDE - 1){
+ return "";
+ }
+ return String.format("1/%.0fx", Math.pow(10, BEST_MAGNITUDE - 1 - i));
+ }
+
+ @Override
+ protected boolean doDrawXAxisMarker(int i) {
+ return i < BEST_MAGNITUDE;
+ }
+
+ @Override
+ protected String legendInsideBar(TeamData teamData) {
+ return "" + teamData.val ;
+ }
+
+ @Override
+ double maxBarWidthWithLegend() {
+ return maxBarWidth(); // - textWidth(" iterations") -1;
+ }
+
+ @Override
+ protected int renderXLegend(Graphics graphics, int y, int axisX) {
+ int x = axisX;
+ String legend = "iterations of test cycles performed in fixed time (more is better)";
+ graphics.setFont(graphData().turnLegendFont);
+ graphics.drawString(legend, x, (int)(y+graphData().markerHeight+textHeight(legend)));
+ return (int) (y + stride()*2);
+ }
+
+}
Property changes on: trunk/polepos/src/org/polepos/reporters/LinearFixedTimeCustomBarRenderer.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/polepos/src/org/polepos/reporters/LinearTimedLapsCustomBarRenderer.java
===================================================================
--- trunk/polepos/src/org/polepos/reporters/LinearTimedLapsCustomBarRenderer.java (rev 0)
+++ trunk/polepos/src/org/polepos/reporters/LinearTimedLapsCustomBarRenderer.java 2011-07-18 16:51:14 UTC (rev 210)
@@ -0,0 +1,73 @@
+/*
+This file is part of the PolePosition database benchmark
+http://www.polepos.org
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public
+License along with this program; if not, write to the Free
+Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+MA 02111-1307, USA. */
+package org.polepos.reporters;
+
+import java.awt.*;
+
+public class LinearTimedLapsCustomBarRenderer extends TimedLapsCustomBarRendererBase {
+
+ public LinearTimedLapsCustomBarRenderer(Graph graph) {
+ super(graph);
+ }
+
+ @Override
+ protected int barWidth(TeamData teamData) {
+ return (int) (((double)teamData.val / (double)graph.worst) * (double)maxBarWidthWithLegend() );
+ }
+
+ @Override
+ protected String legendOnRightOfBar(TeamData teamData) {
+ return teamData.val + "ms";
+ }
+
+
+ @Override
+ protected String magnitudeAxisLegend(int i) {
+ if(i == 1){
+ return "best";
+ }
+ return String.format("%.0fx", Math.pow(10, i-1));
+ }
+
+ @Override
+ protected boolean doDrawXAxisMarker(int i) {
+ return true;
+ }
+
+ @Override
+ protected String legendInsideBar(TeamData teamData) {
+ return "";
+ }
+
+ @Override
+ double maxBarWidthWithLegend() {
+ String worst = "" + graph.worst + "ms";
+ return maxBarWidth() - textWidth(worst) -1;
+ }
+
+ @Override
+ protected int renderXLegend(Graphics graphics, int y, int axisX) {
+ int x = axisX;
+ String legend = "time in milliseconds (less is better)";
+ graphics.setFont(graphData().turnLegendFont);
+ graphics.drawString(legend, (int)(x), (int)(y+graphData().markerHeight+textHeight(legend)));
+ return (int) (y + stride()*2);
+ }
+
+}
Property changes on: trunk/polepos/src/org/polepos/reporters/LinearTimedLapsCustomBarRenderer.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Copied: trunk/polepos/src/org/polepos/reporters/LogarithmicFixedTimeCustomBarRenderer.java (from rev 209, trunk/polepos/src/org/polepos/reporters/FixedTimeCustomBarRenderer.java)
===================================================================
--- trunk/polepos/src/org/polepos/reporters/LogarithmicFixedTimeCustomBarRenderer.java (rev 0)
+++ trunk/polepos/src/org/polepos/reporters/LogarithmicFixedTimeCustomBarRenderer.java 2011-07-18 16:51:14 UTC (rev 210)
@@ -0,0 +1,73 @@
+/*
+This file is part of the PolePosition database benchmark
+http://www.polepos.org
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public
+License along with this program; if not, write to the Free
+Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+MA 02111-1307, USA. */
+
+
+package org.polepos.reporters;
+
+import java.util.*;
+
+import org.polepos.framework.*;
+
+public class LogarithmicFixedTimeCustomBarRenderer extends FixedTimeCustomBarRendererBase {
+
+ private static final int BEST_MAGNITUDE = 5;
+
+ public LogarithmicFixedTimeCustomBarRenderer(Graph graph) {
+ super(graph);
+ }
+
+
+ @Override
+ protected int barWidth(TeamData teamData) {
+ return (int)((BEST_MAGNITUDE - barUnits(teamData.orderOfMagnitude)) * widthPerOrderOfMagnitude());
+ }
+
+ @Override
+ protected String legendOnRightOfBar(TeamData teamData) {
+
+ double orderOfMagnitude = teamData.orderOfMagnitude;
+ if(orderOfMagnitude == 1){
+ return "";
+ }
+ return String.format("1/%.1fx", orderOfMagnitude);
+ }
+
+ @Override
+ protected String magnitudeAxisLegend(int i) {
+ if(i == BEST_MAGNITUDE - 1){
+ return "best";
+ }
+ if(i > BEST_MAGNITUDE - 1){
+ return "";
+ }
+ return String.format("1/%.0fx", Math.pow(10, BEST_MAGNITUDE - 1 - i));
+ }
+
+ @Override
+ protected boolean doDrawXAxisMarker(int i) {
+ return i < BEST_MAGNITUDE;
+ }
+
+ @Override
+ protected String legendInsideBar(TeamData teamData) {
+ return teamData.val+ " iterations";
+ }
+
+
+}
Copied: trunk/polepos/src/org/polepos/reporters/LogarithmicTimedLapsCustomBarRenderer.java (from rev 209, trunk/polepos/src/org/polepos/reporters/TimedLapsCustomBarRenderer.java)
===================================================================
--- trunk/polepos/src/org/polepos/reporters/LogarithmicTimedLapsCustomBarRenderer.java (rev 0)
+++ trunk/polepos/src/org/polepos/reporters/LogarithmicTimedLapsCustomBarRenderer.java 2011-07-18 16:51:14 UTC (rev 210)
@@ -0,0 +1,54 @@
+/*
+This file is part of the PolePosition database benchmark
+http://www.polepos.org
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public
+License along with this program; if not, write to the Free
+Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+MA 02111-1307, USA. */
+package org.polepos.reporters;
+
+public class LogarithmicTimedLapsCustomBarRenderer extends TimedLapsCustomBarRendererBase {
+ public LogarithmicTimedLapsCustomBarRenderer(Graph graph) {
+ super(graph);
+ }
+
+ @Override
+ protected int barWidth(TeamData teamData) {
+ return (int) (barUnits(teamData.orderOfMagnitude) * widthPerOrderOfMagnitude());
+ }
+
+ @Override
+ protected String legendInsideBar(TeamData teamData) {
+ return teamData.val+ "ms";
+ }
+
+ @Override
+ protected String legendOnRightOfBar(TeamData teamData) {
+ return String.format("%.1fx", teamData.orderOfMagnitude);
+ }
+
+ @Override
+ protected String magnitudeAxisLegend(int i) {
+ if(i == 1){
+ return "best";
+ }
+ return String.format("%.0fx", Math.pow(10, i-1));
+ }
+
+ @Override
+ protected boolean doDrawXAxisMarker(int i) {
+ return true;
+ }
+
+}
Deleted: trunk/polepos/src/org/polepos/reporters/TimedLapsCustomBarRenderer.java
===================================================================
--- trunk/polepos/src/org/polepos/reporters/TimedLapsCustomBarRenderer.java 2011-07-15 16:00:32 UTC (rev 209)
+++ trunk/polepos/src/org/polepos/reporters/TimedLapsCustomBarRenderer.java 2011-07-18 16:51:14 UTC (rev 210)
@@ -1,104 +0,0 @@
-/*
-This file is part of the PolePosition database benchmark
-http://www.polepos.org
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public
-License along with this program; if not, write to the Free
-Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
-MA 02111-1307, USA. */
-package org.polepos.reporters;
-
-import java.util.*;
-
-import org.polepos.framework.*;
-
-public class TimedLapsCustomBarRenderer extends CustomBarRendererBase {
- public TimedLapsCustomBarRenderer(Graph graph) {
- super(graph);
- }
-
- protected List<TurnData> prepareTurnsData(final Graph graph) {
- List<TurnData> runs = new ArrayList<TurnData>();
-
- final List<TurnSetup> setups = graph.setups();
- List<TeamCar> teamCars = graph.teamCars();
-
- for (final TurnSetup setup : setups) {
-
- TurnData turnData = new TurnData(setup, 0);
- long best = Long.MAX_VALUE;
- for (TeamCar teamCar : teamCars) {
- long time = graph.timeFor(teamCar, setup);
- TeamData teamData = new TeamData(teamCar, 0, time);
- if (time != 0 && time < best) {
- best = time;
- }
- turnData.teams.add(teamData);
- }
- turnData.best = best == 0 ? 1 : best;
-
- for (TeamData teamData : turnData.teams) {
- teamData.orderOfMagnitude = teamData.val / (double)turnData.best;
- }
-
- Collections.sort(turnData.teams, new Comparator<TeamData>() {
-
- @Override
- public int compare(TeamData team1, TeamData team2) {
- long time1 = graph.timeFor(team1.teamCar, setup);
- long time2 = graph.timeFor(team2.teamCar, setup);
-
- if (time1 > time2) {
- return 1;
- }
- if (time1 < time2) {
- return -1;
- }
- return 0;
- }
- });
-
- runs.add(turnData);
- }
- return runs;
- }
-
- @Override
- protected int barWidth(TeamData teamData) {
- return (int) (barUnits(teamData.orderOfMagnitude) * widthPerOrderOfMagnitude());
- }
-
- @Override
- protected String taskLegend() {
- return "ms";
- }
-
- @Override
- protected String magnitudeBarLegend(TeamData teamData) {
- return String.format("%.1fx", teamData.orderOfMagnitude);
- }
-
- @Override
- protected String magnitudeAxisLegend(int i) {
- if(i == 1){
- return "best";
- }
- return String.format("%.0fx", Math.pow(10, i-1));
- }
-
- @Override
- protected boolean doDrawXAxisMarker(int i) {
- return true;
- }
-
-}
Added: trunk/polepos/src/org/polepos/reporters/TimedLapsCustomBarRendererBase.java
===================================================================
--- trunk/polepos/src/org/polepos/reporters/TimedLapsCustomBarRendererBase.java (rev 0)
+++ trunk/polepos/src/org/polepos/reporters/TimedLapsCustomBarRendererBase.java 2011-07-18 16:51:14 UTC (rev 210)
@@ -0,0 +1,86 @@
+/*
+This file is part of the PolePosition database benchmark
+http://www.polepos.org
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public
+License along with this program; if not, write to the Free
+Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+MA 02111-1307, USA. */
+
+package org.polepos.reporters;
+
+import java.util.*;
+
+import org.polepos.framework.*;
+
+public abstract class TimedLapsCustomBarRendererBase extends
+ CustomBarRendererBase {
+
+ public TimedLapsCustomBarRendererBase(Graph graph) {
+ super(graph);
+ }
+
+ protected List<TurnData> prepareTurnsData(final Graph graph) {
+
+ graph.worst = 0;
+
+ List<TurnData> runs = new ArrayList<TurnData>();
+
+ final List<TurnSetup> setups = graph.setups();
+ List<TeamCar> teamCars = graph.teamCars();
+
+ for (final TurnSetup setup : setups) {
+
+ TurnData turnData = new TurnData(setup, 0);
+ long best = Long.MAX_VALUE;
+ long worst = 0;
+ for (TeamCar teamCar : teamCars) {
+ long time = graph.timeFor(teamCar, setup);
+ TeamData teamData = new TeamData(teamCar, 0, time);
+ if (time != 0 && time < best) {
+ best = time;
+ }
+ if(time > graph.worst){
+ graph.worst = time;
+ }
+ turnData.teams.add(teamData);
+ }
+ turnData.best = best == 0 ? 1 : best;
+
+ for (TeamData teamData : turnData.teams) {
+ teamData.orderOfMagnitude = teamData.val / (double)turnData.best;
+ }
+
+ Collections.sort(turnData.teams, new Comparator<TeamData>() {
+
+ @Override
+ public int compare(TeamData team1, TeamData team2) {
+ long time1 = graph.timeFor(team1.teamCar, setup);
+ long time2 = graph.timeFor(team2.teamCar, setup);
+
+ if (time1 > time2) {
+ return 1;
+ }
+ if (time1 < time2) {
+ return -1;
+ }
+ return 0;
+ }
+ });
+
+ runs.add(turnData);
+ }
+ return runs;
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/polepos/src/org/polepos/reporters/TimedLapsCustomBarRendererBase.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|