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

Jewelia : Plaintext, JSON Serialization, Single Database Query, Multiple Database Queries #6829

Merged
merged 40 commits into from
Oct 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
db90ef1
Dockerfile test
donavindebartolo Sep 9, 2021
d0c2b2c
Merge pull request #1 from donavindebartolo/twotests
donavindebartolo Sep 9, 2021
1de0841
fix run.sh
donavindebartolo Sep 9, 2021
b3761b3
Merge pull request #2 from donavindebartolo/twotests
donavindebartolo Sep 9, 2021
cafb697
Merge branch 'TechEmpower:master' into master
donavindebartolo Sep 16, 2021
772a896
Merge branch 'TechEmpower:master' into master
donavindebartolo Sep 20, 2021
3b6c48b
Working Docker build and plaintext/json tests implemented and passing..
donavindebartolo Sep 22, 2021
fc5e621
Merge branch 'master' of https://github.com/donavindebartolo/Framewor…
donavindebartolo Sep 22, 2021
94a72d4
julia_server.jl patch
donavindebartolo Sep 23, 2021
2c25cce
Update julia_server.jl
abrowao Sep 23, 2021
3f96666
Update benchmark_config.json
abrowao Sep 23, 2021
9e9c752
Update julia_server.jl
abrowao Sep 23, 2021
8aacef9
Merge pull request #3 from donavindebartolo/Single_Query_Test
donavindebartolo Sep 24, 2021
0817765
Testing multiple db queries test
donavindebartolo Sep 24, 2021
e55c13b
Testing multiple db queries test
donavindebartolo Sep 24, 2021
1068635
multiple db queries response formatting changes
donavindebartolo Sep 24, 2021
67adb6a
benchmark_config updates
donavindebartolo Sep 24, 2021
902f4ba
More multiple queries formatting
donavindebartolo Sep 24, 2021
39e69ed
Exception handling for multiple queries
donavindebartolo Sep 24, 2021
5a1d926
More handling...
donavindebartolo Sep 24, 2021
31e7624
More handling
donavindebartolo Sep 24, 2021
60bd825
Even more exception handling.....
donavindebartolo Sep 24, 2021
7ede608
Exception handling for multiple queries test
donavindebartolo Sep 24, 2021
c311471
Exception handling for 0
donavindebartolo Sep 24, 2021
c4bf570
Condensing exception handling for multi db queries
donavindebartolo Sep 24, 2021
6977948
Exception handling fixes...
donavindebartolo Sep 24, 2021
512595a
exception changes
donavindebartolo Sep 24, 2021
53f5c47
Rand num changes
donavindebartolo Sep 24, 2021
71d967c
Rand num changes
donavindebartolo Sep 24, 2021
359371b
Array changes
donavindebartolo Sep 24, 2021
12e2101
Added StructTypes
donavindebartolo Sep 24, 2021
b63fdd3
struct fix
donavindebartolo Sep 24, 2021
261fa3b
test
donavindebartolo Sep 24, 2021
168bde2
revert test
donavindebartolo Sep 24, 2021
dd9dce7
Merge pull request #4 from donavindebartolo/multiple_db_queries_test
donavindebartolo Sep 24, 2021
01ab79a
Fix reduncancy/formatting code...
donavindebartolo Sep 24, 2021
e1199af
Fixed response headers
donavindebartolo Sep 24, 2021
ac7429a
Update README.md
Jayenn Sep 24, 2021
a443972
Update README.md
Jayenn Sep 24, 2021
1e48293
Create README.md
Jayenn Sep 24, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions frameworks/Julia/Jewelia/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[deps]
HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3"
JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1"
MySQL = "39abe10b-433b-5dbd-92d4-e302a9df00cd"
StructTypes = "856f2bd8-1eba-4b0a-8007-ebc267875bd4"

[compat]
HTTP = "^0.9.14"
JSON3 = "^1.9.1"
MySQL = "^1.2.1"
StructTypes = "^1.7.3"
13 changes: 13 additions & 0 deletions frameworks/Julia/Jewelia/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Jewelia Benchmark Test

[![Build Status](https://github.com/TechEmpower/FrameworkBenchmarks/workflows/build/badge.svg?branch=master&event=push)](https://github.com/TechEmpower/FrameworkBenchmarks/actions?query=workflow%3Abuild+branch%3Amaster)

This is a submission for [TechEmpower Framework Benchmarks (TFB)](http://www.techempower.com/benchmarks/) using the [Julia](https://julialang.org/) language.

All tests are located in [julia_server.jl](https://github.com/donavindebartolo/FrameworkBenchmarks/tree/master/frameworks/Julia/Jewelia).

### Implemented benchmarks
- [x] JSON serialization
- [x] Single query
- [x] Multiple queries
- [x] Plaintext
26 changes: 26 additions & 0 deletions frameworks/Julia/Jewelia/benchmark_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"framework": "jewelia",
"tests": [{
"default": {
"json_url": "/json",
"plaintext_url": "/plaintext",
"db_url": "/db",
"query_url": "/queries?queries=",
"port": 8080,
"approach": "Realistic",
"classification": "None",
"database": "MySQL",
"framework": "Jewelia",
"language": "Julia",
"flavor": "None",
"orm": "Raw",
"platform": "None",
"webserver": "HTTP.jl",
"os": "Linux",
"database_os": "Linux",
"display_name": "Jewelia",
"notes": "",
"versus": "None"
}
}]
}
22 changes: 22 additions & 0 deletions frameworks/Julia/Jewelia/jewelia.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM ubuntu:latest

ENV DEBIAN_FRONTEND noninteractive

RUN apt-get update -yqq && apt-get install -y
RUN apt-get update -yqq && apt-get install -y wget

RUN wget https://julialang-s3.julialang.org/bin/linux/x64/1.6/julia-1.6.2-linux-x86_64.tar.gz
RUN tar zxvf julia-1.6.2-linux-x86_64.tar.gz
ENV PATH="$PATH:/julia-1.6.2/bin"

RUN rm -f julia-1.6.2-linux-x86_64.tar.gz

COPY ./ ./

RUN julia -e 'import Pkg; Pkg.activate(@__DIR__); Pkg.instantiate()' && julia -e 'import Pkg; Pkg.activate(@__DIR__); Pkg.precompile()'

RUN chmod +x run.sh

EXPOSE 8080

CMD ./run.sh
92 changes: 92 additions & 0 deletions frameworks/Julia/Jewelia/julia_server.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
using Pkg
Pkg.activate(@__DIR__)

using Dates
using HTTP
using MySQL
using JSON3
using StructTypes

struct jsonObj
id::Int
randomNumber::Int
end

StructTypes.StructType(::Type{jsonObj}) = StructTypes.Struct()

HTTP.listen("0.0.0.0" , 8080, reuseaddr = true) do http
target = http.message.target

HTTP.setstatus(http, 200)
HTTP.setheader(http, "Server" => "Julia-HTTP")
HTTP.setheader(http, "Date" => Dates.format(Dates.now(), Dates.RFC1123Format) * " GMT")

if endswith(target, "/plaintext")
HTTP.setheader(http, "Content-Type" => "text/plain")
HTTP.startwrite(http)
write(http, "Hello, World!")

elseif endswith(target, "/json")
HTTP.setheader(http, "Content-Type" => "application/json")
startwrite(http)
JSON3.write(http, (;message = "Hello, World!"))

elseif endswith(target, "/db")
HTTP.setheader(http, "Content-Type" => "application/json")
randNum = rand(1:10000)

conn = DBInterface.connect(MySQL.Connection, "tfb-database", "benchmarkdbuser", "benchmarkdbpass", db="hello_world")
sqlQuery = "SELECT * FROM World WHERE id = $randNum"
results = DBInterface.execute(conn, sqlQuery)
row = first(results)
dbNumber = row[2]
jsonString = "{\"id\":$randNum,\"randomNumber\":$dbNumber}"

startwrite(http)
JSON3.write(http, (JSON3.read(jsonString)))

elseif occursin("/queries", target)
HTTP.setheader(http, "Content-Type" => "application/json")
numQueries = -1

try
numQueries = parse(Int64, (split(target, "="))[2])

catch ArgumentError
numQueries = 1

finally
if numQueries > 500
numQueries = 500
end

if numQueries < 1
numQueries = 1
end
end

# randNumList = rand(Int64, 1:10000, numQueries)
conn = DBInterface.connect(MySQL.Connection, "tfb-database", "benchmarkdbuser", "benchmarkdbpass", db="hello_world")

responseArray = Array{jsonObj}(undef, numQueries)
for i in 1:numQueries
# randNum = randNumList[i]
randNum = rand(1:10000)
sqlQuery = "SELECT * FROM World WHERE id = $randNum"
results = DBInterface.execute(conn, sqlQuery)
row = first(results)
dbNumber = row[2]
responseArray[i] = JSON3.read("{\"id\":$randNum,\"randomNumber\":$dbNumber}", jsonObj)
end

startwrite(http)
JSON3.write(http, responseArray)
# JSON3.write(http, (JSON3.read(responseArray, JSON3.Array)))

else
HTTP.setstatus(http, 404)
startwrite(http)
write(http, "Not Found")

end
end
5 changes: 5 additions & 0 deletions frameworks/Julia/Jewelia/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
for i in $(seq 0 $(($(nproc --all)-1)));
do julia --threads auto julia_server.jl &
done

while : ; do sleep 1 ; done