Skip to content

Commit

Permalink
#55 squares
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Nov 6, 2024
1 parent c9adf7c commit 1088bfc
Show file tree
Hide file tree
Showing 12 changed files with 148 additions and 695 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/make.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,15 @@ jobs:
restore-keys: |
${{ runner.os }}-jdk-${{ matrix.java }}-maven-
- run: make
- run: make README.md
- run: |
set -x
results=$(cat results.md)
export results
perl -i -0777 -pe 's/(?<=<!-- benchmark_begin -->).*(?=<!-- benchmark_end -->)/\n$ENV{results}\n/gs;' README.md
url=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}
export url
perl -i -0777 -pe 's/(?<=\[benchmark-gha\]: ).*(?=\n)/$ENV{url}/gs;' README.md
if: github.ref == 'refs/heads/master'
- uses: peter-evans/create-pull-request@v7
with:
branch: make
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ after/
results.md
gh-pages/
html/
binary/
binary/
*.csv
*.json
dependency-reduced-pom.xml
66 changes: 10 additions & 56 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,14 @@
.ONESHELL:
.SHELLFLAGS := -e -o pipefail -c
SHELL := bash

.PHONY: all clean
.PRECIOUS: %.jar after before
.EXPORT_ALL_VARIABLES:

SHELL=bash
TOTAL=10000000
MULTIPLIER=40

EO_VERSION=0.38.4
JEO_VERSION=0.4.6
OPEO_VERSION=0.2.2
INEO_VERSION=0.3.1
JD_VERSION=1.2.1
HONE_VERSION=0.0.22

all: env results.md html/summary.html
set -e
Expand All @@ -45,68 +40,27 @@ html/summary.html: ./src/main/perl/create-html-summary.pl
./src/main/perl/create-html-summary.pl
echo "<html><body><a href='summary.html'>summary</a></body></html>" > html/index.html

README.md: results.md src/main/perl/inject-into-readme.pl
src/main/perl/inject-into-readme.pl

env:
if [[ "$(MAKE_VERSION)" =~ ^[1-3] ]]; then
echo "Make must be 4+: $(MAKE_VERSION)"
exit 1
fi

results.md: before.time before.jit-time after.time after.jit-time src/main/bash/assemble-results.sh
results.md: before.csv after.csv src/main/bash/assemble-results.sh
src/main/bash/assemble-results.sh > results.md

%.time: %.jar Makefile
set -e
echo "Testing that .JAR works..."
java -jar $< 1
#java -cp $< org.eolang.benchmark.FactorialApplication 1
echo "Running JAR (without JIT), please wait..."
#time=$$(java -Xint -cp $< org.eolang.benchmark.FactorialApplication "${TOTAL}" | cut -d' ' -f2 | cut -d'=' -f2)
time=$$(java -Xint -jar $< ${TOTAL} | grep "time=" | awk -F'time=' '{print $$2}' | awk '{print $$1}')
echo "$${time}" > $@
echo "Took $${time}ms to run JAR (without JIT)"

%.jit-time: %.jar Makefile
set -e
#java -cp $< org.eolang.benchmark.FactorialApplication 1
java -jar $< 1
echo "Collecting the machine binary code of the App.run() method"
mkdir -p binary
phase=$(subst .jar,,$<)
#java '-XX:+UnlockDiagnosticVMOptions' '-XX:CompileCommand=print,*App.run' -cp $< org.eolang.benchmark.FactorialApplication 10000 > binary/$${phase}.txt
java '-XX:+UnlockDiagnosticVMOptions' '-XX:CompileCommand=print,*App.run' -jar $< 10000000 > binary/$${phase}.txt
t=$$(echo ${TOTAL} \* ${MULTIPLIER} | bc | xargs)
echo "Running JAR (with JIT), please wait..."
#time=$$(java -cp $< org.eolang.benchmark.FactorialApplication $${t} | cut -d' ' -f2 | cut -d'=' -f2)
time=$$(java -jar $< $${t} | grep "time=" | awk -F'time=' '{print $$2}' | awk '{print $$1}')
echo "$${time}" > $@
echo "Took $${time}ms to run JAR (with JIT)"
%.csv: %.jar Makefile
java -jar $< -rf csv
mv jmh-result.csv "$@"

%.jar: pom.xml Makefile src/main/java/org/eolang/benchmark/*.java
set -e
base=$(basename $@)
mvn --activate-profiles "$${base}" --update-snapshots clean package "-DfinalName=$${base}" "-Ddirectory=$${base}" \
-Djeo.version=${JEO_VERSION} \
-Deo.version=${EO_VERSION} \
-Dopeo.version=${OPEO_VERSION} \
-Dineo.version=${INEO_VERSION} \
-Djd.version=${JD_VERSION}
mvn --activate-profiles "$${base}" --update-snapshots clean package \
"-DfinalName=$${base}" "-Ddirectory=$${base}" \
-Dhone.version=${HONE_VERSION}
cp "$${base}/$${base}.jar" "$${base}.jar"

quick:
set -e
rm -f before.jar
make before.jar
rm -f target/benchmark-synthetic.jar
mvn package
T=10000000
JIT_OPTS=-XX:+EliminateAllocations
set -x
java $${JIT_OPTS} -cp before.jar org.eolang.benchmark.FactorialApplication $${T}
java $${JIT_OPTS} -cp target/benchmark-synthetic.jar org.eolang.benchmark.FactorialApplication $${T}

clean:
set -e
rm -f *.time
Expand All @@ -115,4 +69,4 @@ clean:
rm -f results.md
rm -rf before
rm -rf after
rm -rf target
rm -rf target
16 changes: 12 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,17 @@ It's a benchmark that puts together:
* [jeo-maven-plugin](https://github.com/objectionary/jeo-maven-plugin)
* [eo-phi-normalizer](https://github.com/objectionary/eo-phi-normalizer)

The goal is to test the performance of Java code before optimization and after,
then comparing the results. Intermediate artifacts are in this
The goal is to test the performance of Java Stream API before
the "stream fusion" optimization
and after it, then comparing the results. Intermediate artifacts are in this
[`summary.html`](https://www.objectionary.com/benchmark/summary.html).
We partially reuse [the benchmark](https://github.com/biboudis/clashofthelambdas)
earlier suggested by
[Biboudis et al.](https://arxiv.org/abs/1406.6631)
and used by
[Møller et al.](https://dl.acm.org/doi/abs/10.1145/3428236).

<!-- benchmark -->
<!-- benchmark_begin -->
This is the summary of the tests performed with the TOTAL set to 10000000,
at 2024-06-17 15:36, on Linux, with 4 CPUs:

Expand All @@ -40,7 +46,7 @@ Java(TM) SE Runtime Environment (build 21.0.3+7-LTS-152)
Java HotSpot(TM) 64-Bit Server VM (build 21.0.3+7-LTS-152, mixed mode, sharing)
```

<!-- benchmark -->
<!-- benchmark_end -->


Check failure on line 51 in README.md

View workflow job for this annotation

GitHub Actions / markdown-lint

Multiple consecutive blank lines [Expected: 1; Actual: 2]
## How to Contribute
Expand All @@ -56,3 +62,5 @@ make
```

You will need [Maven 3.3+](https://maven.apache.org) and Java 11+ installed.

[benchmark-gha]: url

Check failure on line 66 in README.md

View workflow job for this annotation

GitHub Actions / markdown-lint

Link and image reference definitions should be needed [Unused link or image reference definition: "benchmark-gha"] [Context: "[benchmark-gha]: url"]
Loading

0 comments on commit 1088bfc

Please sign in to comment.