Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defn benchmark
- [cacheSize storeSize clientCount latency]
- (let [generatedKeyValues (repeatedly storeSize (fn [] (list (gensym "key") 42)))
- storeItems (apply #'hash-map (flatten generatedKeyValues))
- keyList (map first generatedKeyValues)
- clientRequestList (partition (/ storeSize clientCount) keys)
- dataStore (create-store latency storeItems)
- aCache (create-cache cacheSize dataStore)
- clients (Executors/newFixedThreadPool clientCount)
- work (map (fn [client]
- (fn [] (dorun (map (fn [aKey]
- (cache-get aCache aKey))
- (shuffle (nth clientRequestList client))))))
- (range clientCount))]
- (time (do (doseq
- [future (.invokeAll clients work)]
- (println "moo")
- (.get future)) ;; make it done
- (.shutdown clients)))))
- (defn testLRU
- [cacheSize storeSize clientCount]
- ;; we do eacht test 30 times
- (dotimes [gensym 10]
- (benchmark cacheSize storeSize clientCount 10)))
- (testLRU 10 100 4)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement