ppo2: use time.perf_counter() instead of time.time() for time measurement (#847)
This commit is contained in:
@@ -119,13 +119,13 @@ def learn(*, network, env, total_timesteps, eval_env = None, seed=None, nsteps=2
|
|||||||
eval_epinfobuf = deque(maxlen=100)
|
eval_epinfobuf = deque(maxlen=100)
|
||||||
|
|
||||||
# Start total timer
|
# Start total timer
|
||||||
tfirststart = time.time()
|
tfirststart = time.perf_counter()
|
||||||
|
|
||||||
nupdates = total_timesteps//nbatch
|
nupdates = total_timesteps//nbatch
|
||||||
for update in range(1, nupdates+1):
|
for update in range(1, nupdates+1):
|
||||||
assert nbatch % nminibatches == 0
|
assert nbatch % nminibatches == 0
|
||||||
# Start timer
|
# Start timer
|
||||||
tstart = time.time()
|
tstart = time.perf_counter()
|
||||||
frac = 1.0 - (update - 1.0) / nupdates
|
frac = 1.0 - (update - 1.0) / nupdates
|
||||||
# Calculate the learning rate
|
# Calculate the learning rate
|
||||||
lrnow = lr(frac)
|
lrnow = lr(frac)
|
||||||
@@ -173,7 +173,7 @@ def learn(*, network, env, total_timesteps, eval_env = None, seed=None, nsteps=2
|
|||||||
# Feedforward --> get losses --> update
|
# Feedforward --> get losses --> update
|
||||||
lossvals = np.mean(mblossvals, axis=0)
|
lossvals = np.mean(mblossvals, axis=0)
|
||||||
# End timer
|
# End timer
|
||||||
tnow = time.time()
|
tnow = time.perf_counter()
|
||||||
# Calculate the fps (frame per second)
|
# Calculate the fps (frame per second)
|
||||||
fps = int(nbatch / (tnow - tstart))
|
fps = int(nbatch / (tnow - tstart))
|
||||||
if update % log_interval == 0 or update == 1:
|
if update % log_interval == 0 or update == 1:
|
||||||
|
Reference in New Issue
Block a user