-
Notifications
You must be signed in to change notification settings - Fork 1
/
measure_simspeed.py
28 lines (25 loc) · 944 Bytes
/
measure_simspeed.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import jsbgym_flex
from jsbgym_flex.environment import JsbSimEnv
from jsbgym_flex.tasks import Shaping, MyFlightTask
import toml
from datetime import datetime
cfg = toml.load('gym-jsbsim-cfg_example.toml')
def simCycle(name, env, outer, inner):
print ('Simulation {}: {}x{} steps'.format(name, outer, inner),end='\r')
before = datetime.now()
for _ in range(outer):
env.reset()
for _ in range(inner):
action=env.action_space.sample()
env.step(action)
after = datetime.now()
dt = (after-before)
print ('Simulation {}: {}x{} steps: {}.{}s'.format(name, outer, inner, dt.seconds, dt.microseconds) )
env = jsbgym_flex.environment.JsbSimEnv(cfg = cfg, task_type = MyFlightTask, shaping = Shaping.STANDARD)
name = 'JSBSIM'
simCycle(name, env, 1, 100)
simCycle(name, env, 10, 100)
simCycle(name, env, 1, 10000)
simCycle(name, env, 10, 1000)
simCycle(name, env, 100, 100)
env.close()