Browse Source

implemented rudimentary build file, renamed perf package, included

adapted mandelbrot gui
master
Sebastian Rieger 7 years ago
parent
commit
9e762ae8a0
  1. 23
      VerteilteSysteme-Examples/.settings/org.eclipse.jdt.core.prefs
  2. 96
      VerteilteSysteme-Examples/src/verteiltesysteme/socket/perf/TCPPerfClient.java
  3. 64
      VerteilteSysteme-Examples/src/verteiltesysteme/socket/perf/TCPPerfServer.java

23
VerteilteSysteme-Examples/.settings/org.eclipse.jdt.core.prefs

@ -1,11 +1,12 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.7

96
VerteilteSysteme-Examples/src/verteiltesysteme/perf/TCPPerfClient.java → VerteilteSysteme-Examples/src/verteiltesysteme/socket/perf/TCPPerfClient.java

@ -1,48 +1,48 @@
package verteiltesysteme.perf;
import java.io.*;
import java.net.*;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
class TCPPerfClient {
public static void main(String argv[]) throws Exception {
String hostname = "";
int tcpPort = 36039;
DateFormat df = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
BufferedReader inFromUser = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Bitte geben Sie die Server-Adresse ein: ");
hostname = inFromUser.readLine();
System.out.println("Bitte geben Sie die Anzahl zu übertragender Megabytes ein: ");
Long number = new Long(inFromUser.readLine());
Socket clientSocket = new Socket(hostname, tcpPort);
DataOutputStream outToServer = new DataOutputStream(clientSocket.getOutputStream());
BufferedReader inFromServer = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
long timestampStart = System.currentTimeMillis();
System.out.println("Zeit vor Versand = " + timestampStart + " ms, " + df.format(new Date(timestampStart)));
outToServer.writeBytes(number.toString() + "\n");
char[] buffer = new char[1024 * 1024];
long totalBytesReceived = 0;
int charsRead = inFromServer.read(buffer);
while (charsRead != -1)
{
totalBytesReceived += charsRead;
charsRead = inFromServer.read(buffer);
}
long timestampEnd = System.currentTimeMillis();
System.out.println("Zeit nach Empfang = " + timestampEnd + " ms, " + df.format(new Date(timestampEnd)));
long duration = timestampEnd - timestampStart;
System.out.println("Delay = " + duration + " ms");
double seconds = (duration / 1000.0);
double throughput = (totalBytesReceived / seconds);
System.out.println("Rate = " + (long)throughput + " B/s");
clientSocket.close();
}
}
package verteiltesysteme.socket.perf;
import java.io.*;
import java.net.*;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
class TCPPerfClient {
public static void main(String argv[]) throws Exception {
String hostname = "";
int tcpPort = 36039;
DateFormat df = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
BufferedReader inFromUser = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Bitte geben Sie die Server-Adresse ein: ");
hostname = inFromUser.readLine();
System.out.println("Bitte geben Sie die Anzahl zu übertragender Megabytes ein: ");
Long number = new Long(inFromUser.readLine());
Socket clientSocket = new Socket(hostname, tcpPort);
DataOutputStream outToServer = new DataOutputStream(clientSocket.getOutputStream());
BufferedReader inFromServer = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
long timestampStart = System.currentTimeMillis();
System.out.println("Zeit vor Versand = " + timestampStart + " ms, " + df.format(new Date(timestampStart)));
outToServer.writeBytes(number.toString() + "\n");
char[] buffer = new char[1024 * 1024];
long totalBytesReceived = 0;
int charsRead = inFromServer.read(buffer);
while (charsRead != -1)
{
totalBytesReceived += charsRead;
charsRead = inFromServer.read(buffer);
}
long timestampEnd = System.currentTimeMillis();
System.out.println("Zeit nach Empfang = " + timestampEnd + " ms, " + df.format(new Date(timestampEnd)));
long duration = timestampEnd - timestampStart;
System.out.println("Delay = " + duration + " ms");
double seconds = (duration / 1000.0);
double throughput = (totalBytesReceived / seconds);
System.out.println("Rate = " + (long)throughput + " B/s");
clientSocket.close();
}
}

64
VerteilteSysteme-Examples/src/verteiltesysteme/perf/TCPPerfServer.java → VerteilteSysteme-Examples/src/verteiltesysteme/socket/perf/TCPPerfServer.java

@ -1,32 +1,32 @@
package verteiltesysteme.perf;
import java.io.*;
import java.net.*;
class TCPPerfServer {
public static void main(String argv[]) throws Exception {
int tcpPort = 36039;
Long clientNumberOfMegabytes;
// Server-Socket erzeugen
@SuppressWarnings("resource")
ServerSocket welcomeSocket = new ServerSocket(tcpPort);
while (true) {
Socket connectionSocket = welcomeSocket.accept();
BufferedReader inFromClient = new BufferedReader(new InputStreamReader(connectionSocket.getInputStream()));
BufferedWriter outToClient = new BufferedWriter(new OutputStreamWriter(connectionSocket.getOutputStream()));
char[] buffer = new char[1024 * 1024];
clientNumberOfMegabytes = new Long(inFromClient.readLine());
//System.out.println(clientNumberOfMegabytes);
for (long i = 0; i < clientNumberOfMegabytes; i++) {
outToClient.write(buffer);
//System.out.print(".");
}
outToClient.close();
System.out.print("\n");
}
}
}
package verteiltesysteme.socket.perf;
import java.io.*;
import java.net.*;
class TCPPerfServer {
public static void main(String argv[]) throws Exception {
int tcpPort = 36039;
Long clientNumberOfMegabytes;
// Server-Socket erzeugen
@SuppressWarnings("resource")
ServerSocket welcomeSocket = new ServerSocket(tcpPort);
while (true) {
Socket connectionSocket = welcomeSocket.accept();
BufferedReader inFromClient = new BufferedReader(new InputStreamReader(connectionSocket.getInputStream()));
BufferedWriter outToClient = new BufferedWriter(new OutputStreamWriter(connectionSocket.getOutputStream()));
char[] buffer = new char[1024 * 1024];
clientNumberOfMegabytes = new Long(inFromClient.readLine());
//System.out.println(clientNumberOfMegabytes);
for (long i = 0; i < clientNumberOfMegabytes; i++) {
outToClient.write(buffer);
//System.out.print(".");
}
outToClient.close();
System.out.print("\n");
}
}
}
Loading…
Cancel
Save