some more performance hacks

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@7533 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 14 years ago
parent b2f147d28e
commit b1781d7aae

@ -75,7 +75,7 @@ public class imagetest {
img.setColor(RasterPlotter.BLUE);
img.dot(620, 200, 90, true, 100);
img.setColor(RasterPlotter.RED);
img.arc(300, 270, 30, 70, 0, 360);
img.arc(300, 270, 30, 70, 100);
img.setColor("330000");
img.arc(220, 110, 50, 90, 30, 110);
img.arc(210, 120, 50, 90, 30, 110);
@ -99,7 +99,7 @@ public class imagetest {
}
}*/
img.setColor("0000A0");
img.arc(550, 400, 40, 81, 0, 360);
img.arc(550, 400, 40, 81, 100);
img.setColor("010100");
for (int i = 0; i <= 360; i++) {
img.arc(550, 400, 40, 41 + i/9, 0, i);

@ -186,7 +186,7 @@ public class NetworkGraph {
// draw network circle
networkPicture.setColor(COL_DHTCIRCLE);
networkPicture.arc(width / 2, height / 2, innerradius - 20, innerradius + 20, 0, 360);
networkPicture.arc(width / 2, height / 2, innerradius - 20, innerradius + 20, 100);
//System.out.println("Seed Maximum distance is " + yacySeed.maxDHTDistance);
//System.out.println("Seed Minimum distance is " + yacySeed.minDHTNumber);
@ -343,7 +343,7 @@ public class NetworkGraph {
img.arcArc(centerX, centerY, innerradius, angle, dotsize + radius, dotsize + radius, a, a + 180/segments);
}
} else {
img.arcArc(centerX, centerY, innerradius, angle, dotsize + radius, dotsize + radius, 0, 360);
img.arcArc(centerX, centerY, innerradius, angle, dotsize + radius, dotsize + radius, 100);
}
}
}

@ -137,7 +137,7 @@ public class OSMTile {
// see http://wiki.openstreetmap.org/wiki/Slippy_map_tilenames
this.zoom = zoom;
this.xtile = (int) Math.floor((lon + 180) / 360 * (1 << zoom));
this.ytile = (int) Math.floor((1 - Math.log(Math.tan(lat * Math.PI / 180) + 1 / Math.cos(lat * Math.PI / 180)) / Math.PI) / 2 * (1 << zoom));
this.ytile = (int) Math.floor((1 - Math.log(Math.tan(lat * RasterPlotter.PI180) + 1 / Math.cos(lat * RasterPlotter.PI180)) / Math.PI) / 2 * (1 << zoom));
}
public tileCoordinates(final int xtile, final int ytile, final int zoom) {

@ -86,7 +86,12 @@ public class Gap extends TreeMap<Long, Integer> {
public int dump(File file) throws IOException {
File tmp = new File(file.getParentFile(), file.getName() + ".prt");
Iterator<Map.Entry<Long, Integer>> i = this.entrySet().iterator();
DataOutputStream os = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(tmp), 4 * 1024 * 1024));
DataOutputStream os;
try {
os = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(tmp), 4 * 1024 * 1024));
} catch (OutOfMemoryError e) {
os = new DataOutputStream(new FileOutputStream(tmp));
}
int c = 0;
Map.Entry<Long, Integer> e;
while (i.hasNext()) {

@ -80,7 +80,12 @@ public final class HeapWriter {
this.heapFileREADY = readyHeapFile;
this.keylength = keylength;
this.index = new HandleMap(keylength, ordering, 8, 100000, readyHeapFile.getAbsolutePath());
this.os = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(temporaryHeapFile), outBuffer));
try {
this.os = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(temporaryHeapFile), outBuffer));
} catch (OutOfMemoryError e) {
// try this again without buffer
this.os = new DataOutputStream(new FileOutputStream(temporaryHeapFile));
}
this.seek = 0;
}

@ -146,12 +146,17 @@ public class MapHeap implements Map<byte[], Map<String, String>> {
String s = map2string(newMap, "W" + my_SHORT_SECOND_FORMATTER.format() + " ");
assert s != null;
byte[] sb = s.getBytes();
synchronized (this) {
if (cache == null) {
// write entry
if (blob != null) blob.insert(key, sb);
if (blob != null) blob.insert(key, sb);
} else {
synchronized (this) {
// write entry
if (blob != null) blob.insert(key, sb);
// write map to cache
if (cache != null) cache.put(key, newMap);
// write map to cache
cache.put(key, newMap);
}
}
}

@ -151,7 +151,12 @@ public final class HandleMap implements Iterable<Row.Entry> {
// everything much faster, but this is not an option here.
final File tmp = new File(file.getParentFile(), file.getName() + ".prt");
final Iterator<Row.Entry> i = this.index.rows(true, null);
OutputStream os = new BufferedOutputStream(new FileOutputStream(tmp), 4 * 1024 * 1024);
OutputStream os;
try {
os = new BufferedOutputStream(new FileOutputStream(tmp), 4 * 1024 * 1024);
} catch (OutOfMemoryError e) {
os = new FileOutputStream(tmp);
}
if (file.getName().endsWith(".gz")) os = new GZIPOutputStream(os);
int c = 0;
while (i.hasNext()) {

@ -112,7 +112,12 @@ public final class HandleSet implements Iterable<byte[]>, Cloneable {
// otherwise we could just write the byte[] from the in kelondroRowSet which would make
// everything much faster, but this is not an option here.
final Iterator<Row.Entry> i = this.index.rows(true, null);
final OutputStream os = new BufferedOutputStream(new FileOutputStream(file), 1024 * 1024);
OutputStream os;
try {
os = new BufferedOutputStream(new FileOutputStream(file), 1024 * 1024);
} catch (OutOfMemoryError e) {
os = new FileOutputStream(file);
}
int c = 0;
while (i.hasNext()) {
os.write(i.next().bytes());

@ -101,7 +101,7 @@ public class CircleTool {
return circles[radius - 1];
}
public static void circle(final RasterPlotter matrix, final int xc, final int yc, final int radius, int intensity) {
public static void circle(final RasterPlotter matrix, final int xc, final int yc, final int radius, final int intensity) {
if (radius == 0) {
//matrix.plot(xc, yc, 100);
} else {

@ -111,8 +111,8 @@ public class PrintTool {
private static final int arcDist = 8;
public static void arcPrint(final RasterPlotter matrix, final int cx, final int cy, final int radius, final int angle, final String message) {
final int x = cx + (int) ((radius + 1) * Math.cos(Math.PI * angle / 180));
final int y = cy - (int) ((radius + 1) * Math.sin(Math.PI * angle / 180));
final int x = cx + (int) ((radius + 1) * Math.cos(RasterPlotter.PI180 * angle));
final int y = cy - (int) ((radius + 1) * Math.sin(RasterPlotter.PI180 * angle));
int yp = y + 3;
if ((angle > arcDist) && (angle < 180 - arcDist)) yp = y;
if ((angle > 180 + arcDist) && (angle < 360 - arcDist)) yp = y + 6;

@ -50,6 +50,8 @@ import net.yacy.kelondro.util.MemoryControl;
public class RasterPlotter {
public static final double PI180 = Math.PI / 180.0d;
// colors regarding RGB Color Model
public static final long RED = 0xFF0000;
public static final long GREEN = 0x00FF00;
@ -211,8 +213,8 @@ public class RasterPlotter {
public void line(
int Ax, int Ay, final int Bx, final int By,
String colorLine, final int intensityLine,
String colorDot, final int intensityDot, int dotDist, int dotPos, int dotRadius, boolean dotFilled
final String colorLine, final int intensityLine,
final String colorDot, final int intensityDot, final int dotDist, final int dotPos, final int dotRadius, final boolean dotFilled
) {
// Bresenham's line drawing algorithm
int dX = Math.abs(Bx-Ax);
@ -301,7 +303,7 @@ public class RasterPlotter {
return grid.getPixel(x, y, c);
}
public void dot(final int x, final int y, final int radius, final boolean filled, int intensity) {
public void dot(final int x, final int y, final int radius, final boolean filled, final int intensity) {
if (filled) {
for (int r = radius; r >= 0; r--) {
CircleTool.circle(this, x, y, r, intensity);
@ -311,16 +313,21 @@ public class RasterPlotter {
}
}
public void arc(final int x, final int y, final int innerRadius, final int outerRadius, final int intensity) {
for (int r = innerRadius; r <= outerRadius; r++) {
CircleTool.circle(this, x, y, r, intensity);
}
}
public void arc(final int x, final int y, final int innerRadius, final int outerRadius, final int fromArc, final int toArc) {
for (int r = innerRadius; r <= outerRadius; r++) {
CircleTool.circle(this, x, y, r, fromArc, toArc);
}
}
public void arcLine(final int cx, final int cy, final int innerRadius, final int outerRadius, final int angle,
boolean in,
String colorLine, String colorDot, int dotDist, int dotPos, int dotRadius, boolean dotFilled) {
final double a = Math.PI * ((double) angle) / 180.0;
public void arcLine(final int cx, final int cy, final int innerRadius, final int outerRadius, final int angle, final boolean in,
final String colorLine, final String colorDot, final int dotDist, final int dotPos, final int dotRadius, final boolean dotFilled) {
final double a = PI180 * ((double) angle);
final double cosa = Math.cos(a);
final double sina = Math.sin(a);
final int xi = cx + (int) (innerRadius * cosa);
@ -344,18 +351,17 @@ public class RasterPlotter {
}
public void arcDot(final int cx, final int cy, final int arcRadius, final int angle, final int dotRadius) {
final double a = Math.PI * ((double) angle) / 180.0;
final double a = PI180 * ((double) angle);
final int x = cx + (int) (arcRadius * Math.cos(a));
final int y = cy - (int) (arcRadius * Math.sin(a));
dot(x, y, dotRadius, true, 100);
}
public void arcConnect(final int cx, final int cy, final int arcRadius, final int angle1, final int angle2,
boolean in,
String colorLine, final int intensityLine,
String colorDot, final int intensityDot, int dotDist, int dotPos, int dotRadius, boolean dotFilled) {
final double a1 = Math.PI * ((double) angle1) / 180.0;
final double a2 = Math.PI * ((double) angle2) / 180.0;
public void arcConnect(final int cx, final int cy, final int arcRadius, final int angle1, final int angle2, final boolean in,
final String colorLine, final int intensityLine,
final String colorDot, final int intensityDot, final int dotDist, final int dotPos, final int dotRadius, final boolean dotFilled) {
final double a1 = PI180 * ((double) angle1);
final double a2 = PI180 * ((double) angle2);
final int x1 = cx + (int) (arcRadius * Math.cos(a1));
final int y1 = cy - (int) (arcRadius * Math.sin(a1));
final int x2 = cx + (int) (arcRadius * Math.cos(a2));
@ -371,8 +377,17 @@ public class RasterPlotter {
}
}
public void arcArc(final int cx, final int cy, final int arcRadius, final int angle, final int innerRadius, final int outerRadius, final int fromArc, final int toArc) {
final double a = Math.PI * ((double) angle) / 180.0;
public void arcArc(final int cx, final int cy, final int arcRadius, final int angle,
final int innerRadius, final int outerRadius, final int intensity) {
final double a = PI180 * ((double) angle);
final int x = cx + (int) (arcRadius * Math.cos(a));
final int y = cy - (int) (arcRadius * Math.sin(a));
arc(x, y, innerRadius, outerRadius, intensity);
}
public void arcArc(final int cx, final int cy, final int arcRadius, final int angle,
final int innerRadius, final int outerRadius, final int fromArc, final int toArc) {
final double a = PI180 * ((double) angle);
final int x = cx + (int) (arcRadius * Math.cos(a));
final int y = cy - (int) (arcRadius * Math.sin(a));
arc(x, y, innerRadius, outerRadius, fromArc, toArc);

Loading…
Cancel
Save