Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better Bf2 Java implementation. #173

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

renatoathaydes
Copy link

This PR implements brainfuck2 in Java that runs much faster than the current implementation.

The code is still pretty clean and very readable, besides being more testable.

On my system, here are the figures I am getting comparing the new implementation with the current one, as well as with the Kotlin (current fastest in the project README) implementation:

  • in seconds
Java (current) Java (new) Kotlin
2.6 1.4 2.0

The Kotlin implementation is also not optimal, I will make a PR offering a faster implementation for it as well.

@renatoathaydes
Copy link
Author

I need to clarify that the times I posted above is when running Java 8 with the GraalVM's JIT.

On the Oracle JVM, there's a performance issue with the Java version, so it runs much slower than Kotlin.

Here's my data:

Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)

  • Java (new): first run and subsequent runs: 3.6 seconds
  • Java (current): first run: 4.3 seconds. Subsequent runs: 3.0 seconds
  • Kotlin: first run: 1.2 seconds. Subsequent runs: 1.55 seconds.

OpenJDK 64-Bit GraalVM CE 19.0.2 (build 25.212-b03-jvmci-19-b04, mixed mode)

  • Java (new): first run: 1.48 seconds. Subsequent runs: 1.43 seconds
  • Java (current): first run and subsequent runs: 2.5 seconds.
  • Kotlin: first run: 2.0 seconds. Subsequent runs: 1.96 seconds.

So, the performance depends a lot on which JIT is used for Java.

@renatoathaydes
Copy link
Author

For comparison, the Go implementation on my machine runs in about 2.0 seconds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant