Skip to content

Commit

Permalink
Replaced deprecated (since Python 3.3) time.clock() methods by `tim…
Browse files Browse the repository at this point in the history
…e.process_time()`.
  • Loading branch information
CYBERDEViLNL committed Dec 18, 2019
1 parent 8e0212d commit a5815c6
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions rpcore/loader.py
Expand Up @@ -51,10 +51,10 @@ def __init__(self, resource):
self.resource = ', '.join(self.resource)

def __enter__(self):
self.start_time = time.clock()
self.start_time = time.process_time()

def __exit__(self, *args):
duration = (time.clock() - self.start_time) * 1000.0
duration = (time.process_time() - self.start_time) * 1000.0
if duration > 80.0 and timed_loading_operation.WARNING_COUNT < 5:
RPObject.global_warn(
"RPLoader", "Loading '" + self.resource + "' took", round(duration, 2), "ms")
Expand Down
4 changes: 2 additions & 2 deletions rpcore/render_pipeline.py
Expand Up @@ -189,7 +189,7 @@ def create(self, base=None):
# when we finished, so we can measure how long it took to render the
# first frame (where the shaders are actually compiled)
init_duration = (time.time() - start_time)
self._first_frame = time.clock()
self._first_frame = time.process_time()
self.debug("Finished initialization in {:3.3f} s, first frame: {}".format(
init_duration, Globals.clock.get_frame_count()))

Expand Down Expand Up @@ -567,7 +567,7 @@ def _plugin_post_render_update(self, task):
update hook. """
self.plugin_mgr.trigger_hook("post_render_update")
if self._first_frame is not None:
duration = time.clock() - self._first_frame
duration = time.process_time() - self._first_frame
self.debug("Took", round(duration, 3), "s until first frame")
self._first_frame = None
return task.cont
Expand Down
4 changes: 2 additions & 2 deletions rpcore/util/generic.py
Expand Up @@ -90,10 +90,10 @@ def __init__(self, name):
self.name = name

def __enter__(self):
self.start_time = time.clock()
self.start_time = time.process_time()

def __exit__(self, *args):
duration = (time.clock() - self.start_time) * 1000.0
duration = (time.process_time() - self.start_time) * 1000.0
print(self.name, "took", round(duration, 2), "ms ")


Expand Down
4 changes: 2 additions & 2 deletions rplibs/yaml/__init__.py
Expand Up @@ -25,7 +25,7 @@ def load_yaml_file(filename):
""" This method is a wrapper arround yaml_load, and provides error checking """

import time
start = time.clock()
start = time.process_time()

try:
with open(filename, "r") as handle:
Expand All @@ -39,7 +39,7 @@ def load_yaml_file(filename):
RPObject.global_error("YAMLLoader", msg)
raise Exception("Failed to load YAML file: Invalid syntax")

duration = (time.clock() - start) * 1000.0
duration = (time.process_time() - start) * 1000.0

# Optionally print out profiling information
# print("Took", round(duration, 2), "ms to load", filename)
Expand Down

0 comments on commit a5815c6

Please sign in to comment.