Last active
November 10, 2020 00:07
-
-
Save staticfloat/370dda9f97e68c5adfbee2357bd7bbcc to your computer and use it in GitHub Desktop.
Bukdu.jl performance test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Bukdu, LinearAlgebra | |
struct RestController <: ApplicationController | |
conn::Conn | |
end | |
function long(c::RestController) | |
sleep(1) | |
render(JSON, 10) | |
end | |
function long_busy(c::RestController) | |
# Simulate actually being busy with work | |
t = time() | |
x = randn(10,10) | |
while time() < t + 1 | |
x = x * (x.^2 + I) | |
end | |
render(JSON, 12) | |
end | |
function long_busy_threaded(c::RestController) | |
# Launch some work on another thread | |
worker = Threads.@spawn begin | |
t = time() | |
x = randn(10,10) | |
# This should pretty much just result in zeros | |
while time() < t + 1 | |
x = x * (x / (norm(x) .+ eps(eltype(x)))) | |
end | |
# This should pretty much always return zero | |
return round(Int, sum(abs.(x))) | |
end | |
# Wait for that thread to be done (frees this thread to process future requests) | |
val = fetch(worker) | |
render(JSON, 1000 + val) | |
end | |
function short(c::RestController) | |
render(JSON, 11) | |
end | |
routes() do | |
get("/long", RestController, long) | |
get("/long_busy", RestController, long_busy) | |
get("/long_busy_threaded", RestController, long_busy_threaded) | |
get("/short", RestController, short) | |
end | |
Bukdu.start(8080) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This file is machine-generated - editing it directly is not advised | |
[[Artifacts]] | |
deps = ["Pkg"] | |
git-tree-sha1 = "c30985d8821e0cd73870b17b0ed0ce6dc44cb744" | |
uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33" | |
version = "1.3.0" | |
[[Base64]] | |
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" | |
[[Bukdu]] | |
deps = ["Dates", "Documenter", "HTTP", "InteractiveUtils", "JSON", "Logging", "MbedTLS", "Sockets", "URIParser"] | |
git-tree-sha1 = "6de1276ef1997d7efd0f1dffda3ed28cad1e4652" | |
uuid = "3e78a19a-cc83-51d8-955b-515f39fd7955" | |
version = "0.4.15" | |
[[Dates]] | |
deps = ["Printf"] | |
uuid = "ade2ca70-3891-5945-98fb-dc099432e06a" | |
[[Distributed]] | |
deps = ["Random", "Serialization", "Sockets"] | |
uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b" | |
[[DocStringExtensions]] | |
deps = ["LibGit2", "Markdown", "Pkg", "Test"] | |
git-tree-sha1 = "50ddf44c53698f5e784bbebb3f4b21c5807401b1" | |
uuid = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae" | |
version = "0.8.3" | |
[[Documenter]] | |
deps = ["Base64", "Dates", "DocStringExtensions", "InteractiveUtils", "JSON", "LibGit2", "Logging", "Markdown", "REPL", "Test", "Unicode"] | |
git-tree-sha1 = "395fa1554c69735802bba37d9e7d9586fd44326c" | |
uuid = "e30172f5-a6a5-5a46-863b-614d45cd2de4" | |
version = "0.24.11" | |
[[HTTP]] | |
deps = ["Base64", "Dates", "IniFile", "MbedTLS", "Sockets"] | |
git-tree-sha1 = "c7ec02c4c6a039a98a15f955462cd7aea5df4508" | |
uuid = "cd3eb016-35fb-5094-929b-558a96fad6f3" | |
version = "0.8.19" | |
[[IniFile]] | |
deps = ["Test"] | |
git-tree-sha1 = "098e4d2c533924c921f9f9847274f2ad89e018b8" | |
uuid = "83e8ac13-25f8-5344-8a64-a9f2b223428f" | |
version = "0.5.0" | |
[[InteractiveUtils]] | |
deps = ["Markdown"] | |
uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240" | |
[[JLLWrappers]] | |
git-tree-sha1 = "c70593677bbf2c3ccab4f7500d0f4dacfff7b75c" | |
uuid = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210" | |
version = "1.1.3" | |
[[JSON]] | |
deps = ["Dates", "Mmap", "Parsers", "Unicode"] | |
git-tree-sha1 = "81690084b6198a2e1da36fcfda16eeca9f9f24e4" | |
uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" | |
version = "0.21.1" | |
[[LibGit2]] | |
deps = ["Printf"] | |
uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" | |
[[Libdl]] | |
uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" | |
[[Logging]] | |
uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" | |
[[Markdown]] | |
deps = ["Base64"] | |
uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" | |
[[MbedTLS]] | |
deps = ["Dates", "MbedTLS_jll", "Random", "Sockets"] | |
git-tree-sha1 = "1c38e51c3d08ef2278062ebceade0e46cefc96fe" | |
uuid = "739be429-bea8-5141-9913-cc70e7f3736d" | |
version = "1.0.3" | |
[[MbedTLS_jll]] | |
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] | |
git-tree-sha1 = "0eef589dd1c26a3ac9d753fe1a8bcad63f956fa6" | |
uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1" | |
version = "2.16.8+1" | |
[[Mmap]] | |
uuid = "a63ad114-7e13-5084-954f-fe012c677804" | |
[[Parsers]] | |
deps = ["Dates"] | |
git-tree-sha1 = "6fa4202675c05ba0f8268a6ddf07606350eda3ce" | |
uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0" | |
version = "1.0.11" | |
[[Pkg]] | |
deps = ["Dates", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "UUIDs"] | |
uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" | |
[[Printf]] | |
deps = ["Unicode"] | |
uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7" | |
[[REPL]] | |
deps = ["InteractiveUtils", "Markdown", "Sockets"] | |
uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" | |
[[Random]] | |
deps = ["Serialization"] | |
uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" | |
[[SHA]] | |
uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" | |
[[Serialization]] | |
uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" | |
[[Sockets]] | |
uuid = "6462fe0b-24de-5631-8697-dd941f90decc" | |
[[Test]] | |
deps = ["Distributed", "InteractiveUtils", "Logging", "Random"] | |
uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" | |
[[URIParser]] | |
deps = ["Unicode"] | |
git-tree-sha1 = "53a9f49546b8d2dd2e688d216421d050c9a31d0d" | |
uuid = "30578b45-9adc-5946-b283-645ec420af67" | |
version = "0.4.1" | |
[[UUIDs]] | |
deps = ["Random", "SHA"] | |
uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" | |
[[Unicode]] | |
uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[deps] | |
Bukdu = "3e78a19a-cc83-51d8-955b-515f39fd7955" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [[ -z $(which ab) ]]; then | |
echo "Must install `ab`! Usually can be found in `apache2-utils`" >&2 | |
exit 1 | |
fi | |
RESOURCE=${1:-short} | |
NUM_TRIALS=${2:-5000} | |
NUM_THREADS=${3:-1000} | |
ab -n ${NUM_TRIALS} -c ${NUM_THREADS} http://localhost:8080/${RESOURCE} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment