0

我一直在尝试测试网络性能,但有一个问题

static public void main(String[] args) 
{
    MPI.Init(args);
    int myrank = MPI.COMM_WORLD.Rank();
    int tag = 99;
    int maxlen = 104857600; 
    int minlen = 1; //1kb ?
    char [] sendbuff = new char [maxlen];
    char [] recvbuff = new char [maxlen];
    long speedKbps;
    long speedMbps;
    if (myrank == 0) 
    {
        for (int len = minlen; len <= maxlen; len *= 2) 
        { //len=*2 doubles the ping size each time
            long startTime = System.nanoTime();                  
            MPI.COMM_WORLD.Send(sendbuff, 0, len, MPI.CHAR, 1, tag);
            MPI.COMM_WORLD.Recv(recvbuff, 0, len, MPI.CHAR, 1, tag);
            long endTime = System.nanoTime();
            long duration = endTime - startTime;
            System.out.println("Time for the ping to be sent and recived of " + len + " kb is " + duration + " nanoseconds");
            double transferRate = (len/ duration ) ; //amount of data in kilobytes transferred in 1 second
            System.out.println("transferRate: " + transferRate + "KB per second");
        }
    }
}

,这minlen = 1是什么大小,是 1 KB,1 位,1 字节吗?

谢谢

4

2 回答 2

2

由于您的发送缓冲区使用 char 作为数据类型,因此它是字节。

于 2013-04-13T21:46:04.633 回答
1

由于您是从字符数组发送项目,因此循环的每次迭代中的 len 是要发送的字符数。所以 minlen=1 的大小是 1 个字符的大小,在 Java 中是 2 个字节。

Java char 大小的来源

于 2013-04-13T21:49:26.230 回答