Commit de9bb981 authored by Noric Couderc's avatar Noric Couderc

Added script for easy running

Updated the documentation as well.
parent 52b768bd
......@@ -50,14 +50,19 @@ To set up the python enviroment to run the python scripts:
## How to train the JBrainy classifier
If you're lazy, you can run the script `jmh-and-train.sh`.
Otherwise, keep reading.
### More about training
To train, you need three things:
- JMH benchmark data
- Software counters data
- Hardware counters data
- Feature vectors data
### JMH Data
First you need to run JMH to get the times that benchmarks take.
### Getting JMH Data
You need to run JMH to get the times that benchmarks take.
./gradlew jmhFull
......@@ -72,39 +77,25 @@ It's contents will look like this:
"se.lth.cs.jmh.ListApplicationBenchmark.ListApplicationBenchmark","thrpt",1,4,5.095096,3.784726,"ops/ms",100,100,LinkedList,UNIFORM,5
...
### Software counters
Second, you need to get the performance counters.
./gradlew run --args="-i jmh-result.csv --input-type JMH -o <out-file> -ot SOFTWARE-COUNTERS"
You may run `./gradlew run --args="--help"` to get help.
The contents of the produced file should look like this:
benchmark_id,feature,value
Synth:UNIFORM:1:100:List:0:LinkedList,collection,LinkedList
Synth:UNIFORM:1:100:List:0:LinkedList,addAll(java.util.Collection),2
Synth:UNIFORM:1:100:List:0:LinkedList,"add(int,java.lang.Object)",6
Synth:UNIFORM:1:100:List:0:LinkedList,size(),1
Synth:UNIFORM:1:100:List:0:LinkedList,lastIndexOf(java.lang.Object),4
Synth:UNIFORM:1:100:List:0:LinkedList,"addAll(int,java.util.Collection)",5
Synth:UNIFORM:1:100:List:0:LinkedList,toArray(java.lang.Object[]),2
Synth:UNIFORM:1:100:List:0:LinkedList,retainAll(java.util.Collection),4
Synth:UNIFORM:1:100:List:0:LinkedList,equals(java.lang.Object),2
...
### Feature vectors
To get the performance counters, you may run:
To get the feature vectors, you may run:
./gradlew run --args="-i jmh-result.csv --input-type JMH --normalize-features -o <features-out-file> -ot FEATURE-VECTORS"
### Software counters
You can get the software counters with:
./gradlew run --args="-i jmh-result.csv --input-type JMH --normalize-features -o <software-output-file> -ot SOFTWARE-COUNTERS"
The content of the resulting file looks like this:
**Note**: There is some overlap in data between feature vectors and software counters...
benchmark_id,feature,feature_type,value
Synth:UNIFORM:1:100:List:0:LinkedList,collection,collection,LinkedList
Synth:UNIFORM:1:100:List:0:LinkedList,addAll(java.util.Collection),software,0.02
Synth:UNIFORM:1:100:List:0:LinkedList,"add(int,java.lang.Object)",software,0.06
Synth:UNIFORM:1:100:List:0:LinkedList,size(),software,0.01
Synth:UNIFORM:1:100:List:0:LinkedList,lastIndexOf(java.lang.Object),software,0.04
Synth:UNIFORM:1:100:List:0:LinkedList,"addAll(int,java.util.Collection)",software,0.05
Synth:UNIFORM:1:100:List:0:LinkedList,toArray(java.lang.Object[]),software,0.02
Synth:UNIFORM:1:100:List:0:LinkedList,retainAll(java.util.Collection),software,0.04
Synth:UNIFORM:1:100:List:0:LinkedList,equals(java.lang.Object),software,0.02
Synth:UNIFORM:1:100:List:0:LinkedList,listIterator(),software,0.01
### Training the classifier
Once you got the features, you train the classifer using the `train_model.py` script (don't forget to install the requirements first!)
......
#!/usr/bin/env bash
JMH_FILE="jmh-result.csv"
FEATURES_FILE="features-`date -I`.csv"
# GETTING JMH COUNTERS
# Change this to jmhFull if you want to run the full suite
# You can also use existing files with jmh results.
echo "Running JMH..."
./gradlew jmhTest
# GETTING THE FEATURES
echo "Getting the features..."
./gradlew run --args="-i jmh-result.csv --input-type JMH --normalize-features -o $FEATURES_FILE -ot FEATURE-VECTORS"
# Training the model
echo "Training model..."
python3 train_model.py $JMH_FILE $FEATURES_FILE
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment