mirror of
https://github.com/KrisKennaway/ii-vision.git
synced 2024-12-26 21:31:34 +00:00
random.getrandbits() is much faster than random.randint()
This commit is contained in:
parent
edefe649f4
commit
4d9e1e510b
@ -174,7 +174,7 @@ class Video:
|
|||||||
# heap in case we can get back to fixing it exactly
|
# heap in case we can get back to fixing it exactly
|
||||||
# during this frame. Otherwise we'll get to it later.
|
# during this frame. Otherwise we'll get to it later.
|
||||||
heapq.heappush(
|
heapq.heappush(
|
||||||
priorities, (-p, random.randint(0, 10000), page, o))
|
priorities, (-p, random.getrandbits(16), page, o))
|
||||||
|
|
||||||
offsets.append(o)
|
offsets.append(o)
|
||||||
if len(offsets) == 3:
|
if len(offsets) == 3:
|
||||||
@ -210,7 +210,7 @@ class Video:
|
|||||||
priorities = [tuple(data) for data in np.stack((
|
priorities = [tuple(data) for data in np.stack((
|
||||||
-update_priority[pages, offsets],
|
-update_priority[pages, offsets],
|
||||||
# Don't use deterministic order for page, offset
|
# Don't use deterministic order for page, offset
|
||||||
np.random.randint(0, 10000, size=pages.shape[0]),
|
np.random.randint(0, 2**8, size=pages.shape[0]),
|
||||||
pages,
|
pages,
|
||||||
offsets)
|
offsets)
|
||||||
).T.tolist()]
|
).T.tolist()]
|
||||||
@ -366,7 +366,7 @@ class Video:
|
|||||||
|
|
||||||
# TODO: vectorize this with numpy
|
# TODO: vectorize this with numpy
|
||||||
deltas = [
|
deltas = [
|
||||||
(priorities[i], random.randint(0, 10000), candidate_offsets[i])
|
(priorities[i], random.getrandbits(16), candidate_offsets[i])
|
||||||
for i in range(len(candidate_offsets))
|
for i in range(len(candidate_offsets))
|
||||||
]
|
]
|
||||||
heapq.heapify(deltas)
|
heapq.heapify(deltas)
|
||||||
|
Loading…
Reference in New Issue
Block a user