Skip to content

Commit

Permalink
Add Julia implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
szarnyasg committed Nov 6, 2020
1 parent 9d420cb commit bef51c9
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ RUN curl -sL https://deb.nodesource.com/setup_13.x | bash - && \
apt-get install -yq --no-install-recommends \
nodejs

## Julia
RUN wget -q https://julialang-s3.julialang.org/bin/linux/x64/1.5/julia-1.5.2-linux-x86_64.tar.gz -O julia-1.5.2-linux-x86_64.tar.gz && \
tar -x -C /opt -f julia-1.5.2-linux-x86_64.tar.gz && \
mv /opt/julia-1.5.2 /opt/julia && \
ln -s /opt/julia/bin/julia /usr/local/bin/julia

## Kotlin
RUN wget -q https://github.com/JetBrains/kotlin/releases/download/v1.3.50/kotlin-compiler-1.3.50.zip -O kotlin-compiler-1.3.50.zip && \
unzip kotlin-compiler-1.3.50.zip -d /opt/ && \
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ Language | Email(ms) | URI(ms) | IP(ms) | Total(ms)
- **Go**: go 1.14.2
- **Java**: OpenJDK 11.0.7
- **Javascript**: node v13.14.0
- **Julia**: Julia 1.5.2
- **Kotlin**: kotlinc-jvm 1.3.50
- **Nim**: Nim 1.2.0
- **Perl**: perl v5.26.1
Expand Down
7 changes: 7 additions & 0 deletions julia/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Julia Regex Benchmark

## How to run

```sh
julia benchmark.jl <filename>
```
19 changes: 19 additions & 0 deletions julia/benchmark.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
function measure(data, pattern)
start = time()
count = length(collect(eachmatch(pattern, data)))
elapsed = time() - start
elapsed_ms = 1000 * elapsed

println(string(elapsed_ms) * " - " * string(count))
end

if length(ARGS) < 1
println("Usage: julia benchmark.jl <filename>")
exit(1)
end

data = open(f->read(f, String), ARGS[1])

measure(data, r"[\w.+-]+@[\w.-]+\.[\w.-]+")
measure(data, r"[\w]+://[^/\s?#]+[^\s?#]+(?:\?[^\s#]*)?(?:#[^\s]*)?")
measure(data, r"(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9])")
1 change: 1 addition & 0 deletions run-benchmarks.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
'Go' => 'go/bin/benchmark',
'Java' => 'java -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC -classpath java Benchmark',
'Javascript' => 'node javascript/benchmark.js',
'Julia' => 'julia julia/benchmark.jl',
'Kotlin' => 'kotlin kotlin/benchmark.jar',
'Nim' => 'nim/bin/benchmark',
'Perl' => 'perl perl/benchmark.pl',
Expand Down

0 comments on commit bef51c9

Please sign in to comment.