Skip to content

Commit cb1745d

Browse files
authored
Merge pull request #2 from egraphs-good/benchmark
Add comparison benchmark results and benchmarking file
2 parents 4fd946c + 0c4f27c commit cb1745d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+24034
-30
lines changed

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
*.class
2+
jd-cli
3+
jd-cli.jar
4+
jd-cli.bat
5+
tmp/
6+
glpk-5.0/
7+
optimized/

Dockerfile

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,24 @@ FROM ubuntu:14.04.2
33

44
# Install dependencies: Java 6, build essential (to build glpk), wget (to download jd-cli)
55
RUN apt-get update && \
6-
apt-get -y install openjdk-6-jdk build-essential wget
6+
apt-get -y install openjdk-6-jdk build-essential wget git
77

88
# Download the repository
9-
# FIXME: we need to make the repo public for this to work
10-
# RUN git clone [email protected]:egraphs-good/peggy-comparison.git
9+
RUN git clone https://github.com/egraphs-good/peggy-comparison.git
1110

12-
# # Install GLPK. We just need the glpsol executable.
13-
# RUN wget "https://ftp.gnu.org/gnu/glpk/glpk-5.0.tar.gz" && \
14-
# unzip glpk-5.0.tar.gz && cd glpk-5.0 && \
15-
# ./configure && make install && \
16-
# mv examples/glpsol /usr/bin/glpsol && cd glpk-5.0 && rm -rf glpk-5.0
1711

18-
# # Install jd-cli for command line decompiling. We need an old version to work with Java 6.
19-
# RUN wget "https://github.com/intoolswetrust/jd-cli/releases/download/jd-cmd-0.9.2.Final/jd-cli-0.9.2-dist.tar.gz" && tar -xzvf jd-cli-0.9.2-dist.tar.gz
12+
# Install GLPK. We just need the glpsol executable.
13+
RUN wget "https://ftp.gnu.org/gnu/glpk/glpk-5.0.tar.gz" && \
14+
tar -xzvf glpk-5.0.tar.gz && cd glpk-5.0 && \
15+
./configure && make install && \
16+
mv examples/glpsol /usr/bin/glpsol && \
17+
cd .. && rm -rf glpk-5.0 && rm glpk-5.0.tar.gz
18+
19+
# Install jd-cli for command line decompiling. We need an old version to work with Java 6.
20+
RUN wget "https://github.com/intoolswetrust/jd-cli/releases/download/jd-cmd-0.9.2.Final/jd-cli-0.9.2-dist.tar.gz" && \
21+
tar -xzvf jd-cli-0.9.2-dist.tar.gz && \
22+
mv jd-cli peggy-comparison && mv jd-cli.jar peggy-comparison && \
23+
rm jd-cli-0.9.2-dist.tar.gz && rm jd-cli.bat
24+
25+
# Everything we need is in peggy-comparison
26+
WORKDIR /peggy-comparison

Foo.java

Lines changed: 0 additions & 7 deletions
This file was deleted.

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,8 @@ Now run the image.
1616
```
1717
docker run -it peggy
1818
```
19+
20+
# Comparison benchmark
21+
This benchmark is qualitative, based on analysis of the optimized output of peggy on certain small example files. These files are in the `benchmark` directory.
22+
23+
Decompiled output for each of the benchmark Java files is stored in `results`. If you would like to re-generate these files, run `python3 benchmark_peggy.py`. In a Docker container, this took 24 min user time, 41 min total time.

benchmark/failing/UnswitchedLoop.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
public class UnswitchedLoop {
2+
// This causes the encoding of output CFG to never terminate
3+
public int expected(int n) {
4+
int j = 0;
5+
if (n < 0) {
6+
for (int i = 0; i < n; i++) {
7+
System.out.println(i);
8+
j = 2;
9+
j++;
10+
}
11+
} else {
12+
for (int i = 0; i < n; i++) {
13+
System.out.println(i);
14+
j++;
15+
}
16+
}
17+
return j;
18+
}
19+
}

benchmark/passing/BranchHoisting.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
public class BranchHoisting {
2+
public int original(int n) {
3+
int y = 0;
4+
int x = 0;
5+
while (y < 500) {
6+
if (n == 0) {
7+
x = y * 2;
8+
} else {
9+
x = y * 3;
10+
}
11+
y++;
12+
}
13+
return x;
14+
}
15+
16+
public int expected(int n) {
17+
int y = 0;
18+
int x = 0;
19+
while (y < 500) y++;
20+
21+
if (n == 0) {
22+
x = y * 2;
23+
} else {
24+
x = y * 3;
25+
}
26+
27+
return x;
28+
}
29+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
public class ConditionalConstantFolding {
2+
public int original(int x) {
3+
if (x == 5) {
4+
return 4 * x;
5+
} else if (x == 4) {
6+
return 5 * x;
7+
} else {
8+
return 20;
9+
}
10+
}
11+
12+
public int expected() {
13+
return 20;
14+
}
15+
}

benchmark/passing/ConstantFold.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
public class ConstantFold {
2+
public int original() {
3+
int j = 1 + 1;
4+
int k = j * 3;
5+
return k - 10;
6+
}
7+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
public class DeadLoopDeletion {
2+
public int original() {
3+
int j = 3;
4+
for (int i = 0; i < 4; i++) {
5+
j++;
6+
}
7+
j = 2;
8+
return j;
9+
}
10+
11+
}

benchmark/passing/IfTrue.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
public class IfTrue {
2+
public int original(int x) {
3+
if (true) {
4+
return x;
5+
} else {
6+
return x - 1;
7+
}
8+
}
9+
10+
public int expected(int x) {
11+
return x;
12+
}
13+
}

0 commit comments

Comments
 (0)