Skip to content

Commit

Permalink
uploaded usl-modeler 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ozerodb committed Mar 31, 2022
1 parent f3091b1 commit dd2240f
Show file tree
Hide file tree
Showing 13 changed files with 373 additions and 1 deletion.
136 changes: 136 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,117 @@

# Created by https://www.toptal.com/developers/gitignore/api/intellij,java,maven
# Edit at https://www.toptal.com/developers/gitignore?templates=intellij,java,maven

### Intellij ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# AWS User-specific
.idea/**/aws.xml

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr

# CMake
cmake-build-*/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# SonarLint plugin
.idea/sonarlint/

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

### Intellij Patch ###
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721

# *.iml
# modules.xml
# .idea/misc.xml
# *.ipr

# Sonarlint plugin
# https://plugins.jetbrains.com/plugin/7973-sonarlint
.idea/**/sonarlint/

# SonarQube Plugin
# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin
.idea/**/sonarIssues.xml

# Markdown Navigator plugin
# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced
.idea/**/markdown-navigator.xml
.idea/**/markdown-navigator-enh.xml
.idea/**/markdown-navigator/

# Cache file creation bug
# See https://youtrack.jetbrains.com/issue/JBR-2257
.idea/$CACHE_FILE$

# CodeStream plugin
# https://plugins.jetbrains.com/plugin/12206-codestream
.idea/codestream.xml

### Java ###
# Compiled class file
*.class

Expand All @@ -21,3 +135,25 @@

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
replay_pid*

### Maven ###
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
# https://github.com/takari/maven-wrapper#usage-without-binary-jar
.mvn/wrapper/maven-wrapper.jar

# Eclipse m2e generated files
# Eclipse Core
.project
# JDT-specific (Eclipse Java Development Tools)
.classpath

# End of https://www.toptal.com/developers/gitignore/api/intellij,java,maven
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions .idea/artifacts/usl_modeler_jar.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 15 additions & 1 deletion README.md
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>
```
26 changes: 26 additions & 0 deletions pom.xml
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>
3 changes: 3 additions & 0 deletions src/main/java/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Manifest-Version: 1.0
Main-Class: io.github.kotlandpolito.UslModeler

47 changes: 47 additions & 0 deletions src/main/java/io/github/kotlandpolito/UslModeler.java
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");
}
}
}
Loading

0 comments on commit dd2240f

Please sign in to comment.