pragunk commited on
Commit
8884934
·
verified ·
1 Parent(s): a26bc32

Create adaptive_cache/workloads.py

Browse files
Files changed (1) hide show
  1. adaptive_cache/workloads.py +19 -0
adaptive_cache/workloads.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+
3
+ def generate_easy_task(length=100, vocab_size=50):
4
+ """Zipfian (power-law) distribution. Standard web traffic."""
5
+ np.random.seed(42)
6
+ workload = np.random.zipf(1.5, length)
7
+ return np.clip(workload, 1, vocab_size).tolist()
8
+
9
+ def generate_medium_task(length=100, cache_size=10):
10
+ """Sequential scan loop. Defeats standard LRU."""
11
+ sequence = list(range(1, cache_size + 3))
12
+ return (sequence * (length // len(sequence) + 1))[:length]
13
+
14
+ def generate_hard_task(length=100):
15
+ """Shifting working sets. Requires rapid adaptation."""
16
+ np.random.seed(42)
17
+ first_half = np.random.randint(1, 20, length // 2).tolist()
18
+ second_half = np.random.randint(80, 100, length - (length // 2)).tolist()
19
+ return first_half + second_half