OpenCores
URL https://opencores.org/ocsvn/fpga-cf/fpga-cf/trunk

Subversion Repositories fpga-cf

[/] [fpga-cf/] [trunk/] [java/] [src/] [edu/] [byu/] [cc/] [plieber/] [fpgaenet/] [examples/] [ThroughputTest.java] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 peteralieb
/**
2
 *
3
 */
4
package edu.byu.cc.plieber.fpgaenet.examples;
5
 
6
import java.io.IOException;
7
import java.net.InetAddress;
8
import java.util.ArrayList;
9
 
10
import edu.byu.cc.plieber.fpgaenet.fcp.FCPException;
11
import edu.byu.cc.plieber.fpgaenet.fcp.FCPProtocol;
12
 
13
/**
14
 * @author Peter Lieber
15
 *
16
 */
17
public class ThroughputTest {
18
 
19
        /**
20
         * @param args
21
         */
22
        public static void main(String[] args) {
23
                FCPProtocol p = null;
24
                try {
25
                        p = new FCPProtocol();
26
                        p.setSendWindow(10);
27
                        p.connect(InetAddress.getByName("10.0.1.42"));
28
                } catch (IOException e) {
29
                        // TODO Auto-generated catch block
30
                        e.printStackTrace();
31
                }
32
                while (!p.isConnected())
33
                        ;
34
 
35
                ArrayList<Byte> data = new ArrayList<Byte>();
36
                for (int i = 0; i < 1024; i++) {
37
                        data.add(new Byte((byte) 0x0));
38
                }
39
 
40
                long totaltime = 0;
41
                for (int j = 0; j < 10; j++) {
42
                        long time = System.currentTimeMillis();
43
                        for (int i = 0; i < 4096; i++) {
44
                                //data.set(1023, new Byte((byte)i));
45
                                try {
46
                                        p.sendData(1, data, 1024);
47
                                } catch (FCPException e) {
48
                                        // TODO Auto-generated catch block
49
                                        e.printStackTrace();
50
                                }
51
                        }
52
                        while (p.packetsPending())
53
                                ;
54
                        time = System.currentTimeMillis() - time;
55
                        System.out.println("4 MB time: " + time);
56
                        System.out.println("While Count: " + p.getWhileCount());
57
                        p.resetWhileCount();
58
                        totaltime += time;
59
                }
60
                System.out.println("Total Time: " + totaltime + " ms");
61
                System.out.println("Average Throughput: " + 40.0 / ((double)totaltime/ 1000.0) + " MB/s");
62
                System.out.println("Average Throughput: " + 320.0 / ((double)totaltime/ 1000.0) + " Mb/s");
63
                p.disconnect();
64
        }
65
 
66
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.