我有这个类,我通过 RMI 和 kryonet 和 kryo 发送这个类,我得到了 10 个对象的数组,其中包含 rmi,作为远程方法调用的返回,以及 kryonet 从服务器到客户端与 kryonet 的回显和 kryo,我总共有一个 55*10 的对象,其中 555 但 RMI 1196bytes ,
这些结果合理吗
*为什么这些结果是这样的?
为什么有那么大的区别。?
幕后涉及哪些间接费用或其他因素,
这在 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.");
}
}
谢谢。