-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,15 @@ | ||
# usl-modeler | ||
# usl-modeler | ||
|
||
This little repository contains the Java code we put together in order to use [usl4j](github.com/codahale/usl4j) during the first Web Applications II laboratory. | ||
|
||
## Usage | ||
|
||
The program accepts the input filename and the output filename as arguments. | ||
|
||
Using the {concurrency, throughput} pairs in the input file, it models a model that obeys to the the Universal Scalability Law, and writes in the output file the predicted throughput at increasing concurrency levels. | ||
|
||
A command line example is: | ||
|
||
```bash | ||
java -jar usl-modeler.jar <input-file> <output-file> | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>io.github.kotlandpolito</groupId> | ||
<artifactId>usl-modeler</artifactId> | ||
<version>1.0</version> | ||
|
||
<properties> | ||
<maven.compiler.source>8</maven.compiler.source> | ||
<maven.compiler.target>8</maven.compiler.target> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.codahale</groupId> | ||
<artifactId>usl4j</artifactId> | ||
<version>0.7.0</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Manifest-Version: 1.0 | ||
Main-Class: io.github.kotlandpolito.UslModeler | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package io.github.kotlandpolito; | ||
|
||
import com.codahale.usl4j.Measurement; | ||
import com.codahale.usl4j.Model; | ||
|
||
import java.io.FileNotFoundException; | ||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
public class UslModeler { | ||
public static void main(String[] args) { | ||
if (args.length < 2){ | ||
System.out.println("USAGE:\njava -jar usl-modeler-<version>.jar <input-file> <output-file>"); | ||
return; | ||
} | ||
|
||
List<String[]> lines; | ||
try { | ||
lines = Utils.parseCsv(args[0]); | ||
} catch (FileNotFoundException e) { | ||
System.out.println("Couldn't find the specified input file"); | ||
return; | ||
} | ||
|
||
double[][] points = lines.stream() | ||
.map(Utils::stringArrayToDoubleArray) | ||
.toArray(double[][]::new); | ||
|
||
// Map the points to measurements of concurrency and throughput, then build a model from them. | ||
Model model = Arrays.stream(points) | ||
.map(Measurement.ofConcurrency()::andThroughput) | ||
.collect(Model.toModel()); | ||
|
||
// Predict the throughput for various levels of possible concurrency. | ||
List<String[]> outLines = new ArrayList<>(); | ||
for (int i = 1; i < 300; ++i) { | ||
outLines.add(new String[]{String.valueOf(i), String.valueOf(model.throughputAtConcurrency(i))}); | ||
} | ||
|
||
try { | ||
Utils.writeCsv(args[1], outLines); | ||
} catch (FileNotFoundException e) { | ||
System.out.println("Couldn't write to the specified output file"); | ||
} | ||
} | ||
} |