Advertisement
Guest User

Untitled

a guest
Sep 19th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. (defn benchmark
  2. [cacheSize storeSize clientCount latency]
  3. (let [generatedKeyValues (repeatedly storeSize (fn [] (list (gensym "key") 42)))
  4. storeItems (apply #'hash-map (flatten generatedKeyValues))
  5. keyList (map first generatedKeyValues)
  6. clientRequestList (partition (/ storeSize clientCount) keys)
  7. dataStore (create-store latency storeItems)
  8. aCache (create-cache cacheSize dataStore)
  9. clients (Executors/newFixedThreadPool clientCount)
  10. work (map (fn [client]
  11. (fn [] (dorun (map (fn [aKey]
  12. (cache-get aCache aKey))
  13. (shuffle (nth clientRequestList client))))))
  14. (range clientCount))]
  15. (time (do (doseq
  16. [future (.invokeAll clients work)]
  17. (println "moo")
  18. (.get future)) ;; make it done
  19. (.shutdown clients)))))
  20.  
  21. (defn testLRU
  22. [cacheSize storeSize clientCount]
  23. ;; we do eacht test 30 times
  24. (dotimes [gensym 10]
  25. (benchmark cacheSize storeSize clientCount 10)))
  26. (testLRU 10 100 4)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement