Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch time.time to time.monotonic #370

Merged
merged 1 commit into from
Aug 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions piqueserver/scripts/rollback.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def start_rollback(self, connection, mapname, start_x, start_y,
self.packet_generator = self.create_rollback_generator(
self.map, map, start_x, start_y, end_x, end_y, ignore_indestructable)
self.rollback_in_progress = True
self.rollback_start_time = time.time()
self.rollback_start_time = time.monotonic()
self.rollback_last_chat = self.rollback_start_time
self.rollback_rows = 0
self.rollback_total_rows = end_x - start_x
Expand Down Expand Up @@ -139,9 +139,9 @@ def rollback_cycle(self):
sent_total += sent * len(self.connections)
rows += (sent == 0)
self.rollback_rows += rows
if (time.time() - self.rollback_last_chat >
if (time.monotonic() - self.rollback_last_chat >
self.rollback_time_between_progress_updates):
self.rollback_last_chat = time.time()
self.rollback_last_chat = time.monotonic()
progress = float(self.rollback_rows) / \
self.rollback_total_rows
if progress < 1.0:
Expand All @@ -150,7 +150,7 @@ def rollback_cycle(self):
else:
self.send_chat(S_ROLLBACK_COLOR_PASS)
except (StopIteration):
elapsed = time.time() - self.rollback_start_time
elapsed = time.monotonic() - self.rollback_start_time
message = S_ROLLBACK_TIME_TAKEN.format(seconds=elapsed)
self.end_rollback(message)

Expand Down
8 changes: 4 additions & 4 deletions pyspades/vxl.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,11 @@ cdef class VXLData:
return 0
set_point(x, y, z, self.map, 0, 0)
count = 1
start = time.time()
start = time.monotonic()
for node_x, node_y, node_z in self.get_neighbors(x, y, z):
if node_z < 62:
count += self.check_node(node_x, node_y, node_z, True)
taken = time.time() - start
taken = time.monotonic() - start
if taken > 0.1:
print 'destroying block at', x, y, z, 'took:', taken
return count
Expand Down Expand Up @@ -262,9 +262,9 @@ cdef class VXLData:
i += 1

def generate(self):
start = time.time()
start = time.monotonic()
data = save_vxl(self.map)
dt = time.time() - start
dt = time.monotonic() - start
if dt > 1.0:
print 'VXLData.generate() took %s' % (dt)
return data
Expand Down