Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
timer,
cache.memoize(expire=1),
],
('Synchronized Locking', 'synchronized-locking.png'): [
timer,
cache.memoize(expire=0),
dc.barrier(cache, dc.Lock),
cache.memoize(expire=1),
],
('Early Recomputation', 'early-recomputation.png'): [
timer,
dc.memoize_stampede(cache, expire=1),
],
('Early Recomputation (beta=0.5)', 'early-recomputation-05.png'): [
timer,
dc.memoize_stampede(cache, expire=1, beta=0.5),
],
('Early Recomputation (beta=0.3)', 'early-recomputation-03.png'): [
timer,
dc.memoize_stampede(cache, expire=1, beta=0.3),
],
}
for (option, filename), decorators in options.items():
print('Simulating:', option)
worker_times = []
worker = make_worker(worker_times)
for decorator in reversed(decorators):
worker = decorator(worker)
worker()
repeater = make_repeater(worker)
('No Caching', 'no-caching.png'): [
timer,
],
('Traditional Caching', 'traditional-caching.png'): [
timer,
cache.memoize(expire=1),
],
('Synchronized Locking', 'synchronized-locking.png'): [
timer,
cache.memoize(expire=0),
dc.barrier(cache, dc.Lock),
cache.memoize(expire=1),
],
('Early Recomputation', 'early-recomputation.png'): [
timer,
dc.memoize_stampede(cache, expire=1),
],
('Early Recomputation (beta=0.5)', 'early-recomputation-05.png'): [
timer,
dc.memoize_stampede(cache, expire=1, beta=0.5),
],
('Early Recomputation (beta=0.3)', 'early-recomputation-03.png'): [
timer,
dc.memoize_stampede(cache, expire=1, beta=0.3),
],
}
for (option, filename), decorators in options.items():
print('Simulating:', option)
worker_times = []
worker = make_worker(worker_times)
for decorator in reversed(decorators):