Skip to content
This repository has been archived by the owner on May 21, 2022. It is now read-only.

Parametric Episode iterator #31

Merged
merged 1 commit into from
Dec 2, 2018
Merged

Parametric Episode iterator #31

merged 1 commit into from
Dec 2, 2018

Conversation

iblislin
Copy link
Member

@iblislin iblislin commented Dec 1, 2018

  • make it type stable and improve performance

Benchmark script

using Reinforce
env = Reinforce.CartPole()
π′ = RandomPolicy()
Randome.seed!(42)
@benchmark run_episode(x -> x, env, π′)

Before:

julia> @benchmark run_episode(x -> x, env, π′)
BenchmarkTools.Trial:
  memory estimate:  2.39 KiB
  allocs estimate:  92
  --------------
  minimum time:     5.581 μs (0.00% GC)
  median time:      12.884 μs (0.00% GC)
  mean time:        19.578 μs (22.57% GC)
  maximum time:     36.822 ms (99.85% GC)
  --------------
  samples:          10000
  evals/sample:     1

After:

julia> @benchmark run_episode(x -> x, env, π′)
BenchmarkTools.Trial:
  memory estimate:  1.37 KiB
  allocs estimate:  29
  --------------
  minimum time:     981.900 ns (0.00% GC)
  median time:      1.648 μs (0.00% GC)
  mean time:        2.170 μs (22.77% GC)
  maximum time:     3.367 ms (99.93% GC)
  --------------
  samples:          10000
  evals/sample:     10

- make it type stable and improve performance

Benchmark script
```julia
using Reinforce
env = Reinforce.CartPole()
π′ = RandomPolicy()
@benchmark run_episode(x -> x, env, π′)
```

Before:
```
julia> @benchmark run_episode(x -> x, env, π′)
BenchmarkTools.Trial:
  memory estimate:  2.39 KiB
  allocs estimate:  92
  --------------
  minimum time:     5.581 μs (0.00% GC)
  median time:      12.884 μs (0.00% GC)
  mean time:        19.578 μs (22.57% GC)
  maximum time:     36.822 ms (99.85% GC)
  --------------
  samples:          10000
  evals/sample:     1
```

After:
```
julia> @benchmark run_episode(x -> x, env, π′)
BenchmarkTools.Trial:
  memory estimate:  1.37 KiB
  allocs estimate:  29
  --------------
  minimum time:     981.900 ns (0.00% GC)
  median time:      1.648 μs (0.00% GC)
  mean time:        2.170 μs (22.77% GC)
  maximum time:     3.367 ms (99.93% GC)
  --------------
  samples:          10000
  evals/sample:     10
```
@iblislin iblislin merged commit be529b0 into master Dec 2, 2018
@iblislin iblislin deleted the ib/episode-iter branch December 2, 2018 09:06
@JobJob
Copy link
Member

JobJob commented Dec 16, 2018

Nice

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

Successfully merging this pull request may close these issues.

2 participants