私はこのクラスを持っています。私はこのクラスをRMI経由で、kryonetとkryo経由で送信しています。リモートメソッドの戻り値としてrmiの両方を入れて10個のオブジェクトの配列を取得しています。 kryonetとkryoを使用してサーバーからクライアントにエコーする場合、私は1つのオブジェクト55 * 10の555をRMI 1196bytes、カスタムネットワークライブラリとserialzation VSのデフォルトのシリアライゼーションとRMI
としています。
*なぜこれらの結果は同じですか?
なぜそれほど大きな違いがありますか?
オーバーヘッドやその他の要因は、シーンの背後に関与している、RMIでそのくらいの合計とあまり違いを作り、私をポイントしている
。
これは、単一オブジェクトの合計55バイトですか?*です。私はこれらの結果を提示しなければならないよう
は、私はちょうど
私は本当に感謝してます、いくつかの確認や専門家の目を必要としています。
public class TBall {
private float x, y; // Ball's center (x, y)
private float speedX, speedY; // Ball's speed per step in x and y
private float radius; // Ball's radius
private Color color; // Ball's color
public boolean collisionDetected = false;
public static boolean run = false;
private String name;
private float nextX, nextY;
private float nextSpeedX, nextSpeedY;
public TBall() {
super();
}
public TBall(String name1, float x, float y, float radius, float speed,
float angleInDegree, Color color) {
this.x = x;
this.y = y;
// Convert velocity from polar to rectangular x and y.
this.speedX = speed * (float) Math.cos(Math.toRadians(angleInDegree));
this.speedY = speed * (float) Math.sin(Math.toRadians(angleInDegree));
this.radius = radius;
this.color = color;
this.name = name1;
}
public String getName() {
return this.name;
}
public float getSpeed() {
return (float) Math.sqrt(speedX * speedX + speedY * speedY);
}
public float getMoveAngle() {
return (float) Math.toDegrees(Math.atan2(speedY, speedX));
}
public float getRadius() {
return radius;
}
public Color getColor() {
return this.color;
}
public void setColor(Color col) {
this.color = col;
}
public float getX() {
return x;
}
public float getY() {
return y;
}
public void setX(float f) {
x = (int) f;
}
public void setY(float f) {
y = (int) f;
}
public void move() {
if (collisionDetected) {
// Collision detected, use the values computed.
x = nextX;
y = nextY;
speedX = nextSpeedX;
speedY = nextSpeedY;
} else {
// No collision, move one step and no change in speed.
x += speedX;
y += speedY;
}
collisionDetected = false; // Clear the flag for the next step
System.out.println("In serializedBall in move.");
}
public void collideWith() {
float minX = 0 + radius;
float minY = 0 + radius;
float maxX = 0 + 640 - 1 - radius;
float maxY = 0 + 480 - 1 - radius;
double gravAmount = 0.9811111f;
double gravDir = (90/57.2960285258);
// Try moving one full step
nextX = x + speedX;
nextY = y + speedY;
System.out.println("In serializedBall in collision.");
// If collision detected. Reflect on the x or/and y axis
// and place the ball at the point of impact.
if (speedX != 0) {
if (nextX > maxX) { // Check maximum-X bound
collisionDetected = true;
nextSpeedX = -speedX; // Reflect
nextSpeedY = speedY; // Same
nextX = maxX;
nextY = (maxX - x) * speedY/speedX + y; // speedX non-zero
} else if (nextX < minX) { // Check minimum-X bound
collisionDetected = true;
nextSpeedX = -speedX; // Reflect
nextSpeedY = speedY; // Same
nextX = minX;
nextY = (minX - x) * speedY/speedX + y; // speedX non-zero
}
}
// In case the ball runs over both the borders.
if (speedY != 0) {
if (nextY > maxY) { // Check maximum-Y bound
collisionDetected = true;
nextSpeedX = speedX; // Same
nextSpeedY = -speedY; // Reflect
nextY = maxY;
nextX = (maxY - y) * speedX/speedY + x; // speedY non-zero
} else if (nextY < minY) { // Check minimum-Y bound
collisionDetected = true;
nextSpeedX = speedX; // Same
nextSpeedY = -speedY; // Reflect
nextY = minY;
nextX = (minY - y) * speedX/speedY + x; // speedY non-zero
}
}
System.out.println("In serializedBall collision.");
// speedX += Math.cos(gravDir) * gravAmount;
// speedY += Math.sin(gravDir) * gravAmount;
System.out.println("In serializedBall in collision.");
}
}
ありがとう:
これは私の両方で用いたMクラスです。
あなたの返事をありがとう、これは1つのボールオブジェクトを配列に送信した結果、結果(私は見るためにwiresharkを使用しています)は55バイトの移動です。オブジェクトの数を増やすと、配列内のオブジェクトは55倍になります。これは、kryo直列化ライブラリでは55 * 10 = 555です。 RMIとデフォルトのシリアライゼーションでは、配列内の1つのオブジェクトは、575バイトをとり、10は1196をとります。これは、最初のものとはかなり異なり、配列内のオブジェクトに依存しない何らかのオーバーヘッドを示します。そのオーバーヘッドは何ですか? –
@static void main kryoライブラリはある種の圧縮やデフォルト値の削除をしているように見えます。私はすでにRMIとシリアライゼーションのオーバーヘッドについて書いています。 – EJP