Skip to content

Commit

Permalink
fix formatting of benchmarks (#127)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sid-Bhatia-0 authored Feb 18, 2021
1 parent 3490613 commit 2686ca2
Show file tree
Hide file tree
Showing 2 changed files with 1,314 additions and 858 deletions.
75 changes: 39 additions & 36 deletions benchmark/benchmark.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,62 +14,64 @@ information = Dict()

ENVS = [GW.EmptyRoom, GW.GridRooms, GW.SequentialRooms, GW.GoToDoor, GW.DoorKey, GW.CollectGems, GW.DynamicObstacles, GW.Sokoban]

function format_benchmark(str::String)
l = split(str, "\n")
deleteat!(l, (1, 4, 9))
return strip.(l)
end

function write_benchmarks!(information; file = "benchmark.md")
io = open(file, "w")

write(io, "# List of Environments")
write(io, "\n")
write(io, "# List of Environments\n")

for Env in ENVS
write(io, " 1. [$(Symbol(Env))](#$(Symbol(Env)))")
write(io, "\n")
write(io, " 1. [$(Symbol(Env))](#$(Symbol(Env)))\n")
end

write(io, "\n")
write(io, "# Benchmarks")
write(io, "\n")
write(io, "# Benchmarks\n\n")

for Env in ENVS
env_benchmark = information[Symbol(Env)]

write(io, "# $(String(Symbol(Env)))")
write(io, "\n")
write(io, "# $(String(Symbol(Env)))\n\n")

write(io, "#### $(String(Symbol(Env)))()")
write(io, "\n")
write(io, repr("text/plain", env_benchmark[:instantiation]))
write(io, "\n")
write(io, "#### $(String(Symbol(Env)))()\n\n")
for line in format_benchmark(repr("text/plain", env_benchmark[:instantiation]))
write(io, line * "\n\n")
end

write(io, "#### RLBase.reset!(env)")
write(io, "\n")
write(io, repr("text/plain", env_benchmark[:reset!]))
write(io, "\n")
write(io, "#### RLBase.reset!(env)\n\n")
for line in format_benchmark(repr("text/plain", env_benchmark[:reset!]))
write(io, line * "\n\n")
end

write(io, "#### RLBase.state(env)")
write(io, "\n")
write(io, repr("text/plain", env_benchmark[:state]))
write(io, "\n")
write(io, "#### RLBase.state(env)\n\n")
for line in format_benchmark(repr("text/plain", env_benchmark[:state]))
write(io, line * "\n\n")
end

write(io, "#### RLBase.action_space(env)")
write(io, "\n")
write(io, repr("text/plain", env_benchmark[:action_space]))
write(io, "\n")
write(io, "#### RLBase.action_space(env)\n\n")
for line in format_benchmark(repr("text/plain", env_benchmark[:action_space]))
write(io, line * "\n\n")
end

write(io, "#### RLBase.is_terminated(env)")
write(io, "\n")
write(io, repr("text/plain", env_benchmark[:is_terminated]))
write(io, "\n")
write(io, "#### RLBase.is_terminated(env)\n\n")
for line in format_benchmark(repr("text/plain", env_benchmark[:is_terminated]))
write(io, line * "\n\n")
end

write(io, "#### RLBase.reward(env)")
write(io, "\n")
write(io, repr("text/plain", env_benchmark[:reward]))
write(io, "\n")
write(io, "#### RLBase.reward(env)\n\n")
for line in format_benchmark(repr("text/plain", env_benchmark[:reward]))
write(io, line * "\n\n")
end

for action in keys(env_benchmark[:action_info])
write(io, "#### env($action)")
write(io, "\n")
write(io, repr("text/plain", env_benchmark[:action_info][action]))
write(io, "\n")
write(io, "#### env($action)\n\n")
for line in format_benchmark(repr("text/plain", env_benchmark[:action_info][action]))
write(io, line * "\n\n")
end
end

end
Expand Down Expand Up @@ -101,3 +103,4 @@ for Env in ENVS
end

write_benchmarks!(information)

Loading

0 comments on commit 2686ca2

Please sign in to comment.