move misc/Cache to core/CCCache

This commit is contained in:
Simon Cruanes 2014-11-23 13:48:50 +01:00
parent cb311bf764
commit f010bc6ebc
4 changed files with 14 additions and 12 deletions

4
_oasis
View file

@ -48,7 +48,7 @@ Library "containers"
CCHeap, CCList, CCOpt, CCPair, CCFun, CCHash, CCHeap, CCList, CCOpt, CCPair, CCFun, CCHash,
CCKList, CCInt, CCBool, CCArray, CCOrd, CCIO, CCKList, CCInt, CCBool, CCArray, CCOrd, CCIO,
CCRandom, CCKTree, CCTrie, CCString, CCHashtbl, CCRandom, CCKTree, CCTrie, CCString, CCHashtbl,
CCFlatHashtbl, CCSexp, CCMap CCFlatHashtbl, CCSexp, CCMap, CCCache
BuildDepends: bytes BuildDepends: bytes
Library "containers_string" Library "containers_string"
@ -76,7 +76,7 @@ Library "containers_pervasives"
Library "containers_misc" Library "containers_misc"
Path: misc Path: misc
Pack: true Pack: true
Modules: Cache, FHashtbl, FlatHashtbl, Hashset, Modules: FHashtbl, FlatHashtbl, Hashset,
Heap, LazyGraph, PersistentGraph, Heap, LazyGraph, PersistentGraph,
PHashtbl, SkipList, SplayTree, SplayMap, Univ, PHashtbl, SkipList, SplayTree, SplayMap, Univ,
Bij, PiCalculus, RAL, UnionFind, SmallSet, AbsSet, CSM, Bij, PiCalculus, RAL, UnionFind, SmallSet, AbsSet, CSM,

View file

@ -127,8 +127,10 @@ module Vec = struct
end end
module Cache = struct module Cache = struct
module C = CCCache
let make_fib c = let make_fib c =
let f = Cache.with_cache_rec c let f = C.with_cache_rec c
(fun fib n -> match n with (fun fib n -> match n with
| 0 -> 0 | 0 -> 0
| 1 -> 1 | 1 -> 1
@ -137,22 +139,22 @@ module Cache = struct
) )
in in
fun x -> fun x ->
Cache.clear c; C.clear c;
f x f x
let bench_fib n = let bench_fib n =
let l = let l =
[ "replacing_fib (128)", make_fib (Cache.replacing 128), n [ "replacing_fib (128)", make_fib (C.replacing 128), n
; "LRU_fib (128)", make_fib (Cache.lru 128), n ; "LRU_fib (128)", make_fib (C.lru 128), n
; "replacing_fib (16)", make_fib (Cache.replacing 16), n ; "replacing_fib (16)", make_fib (C.replacing 16), n
; "LRU_fib (16)", make_fib (Cache.lru 16), n ; "LRU_fib (16)", make_fib (C.lru 16), n
; "unbounded", make_fib (Cache.unbounded 32), n ; "unbounded", make_fib (C.unbounded 32), n
] ]
in in
let l = if n <= 20 let l = if n <= 20
then [ "linear_fib (5)", make_fib (Cache.linear 5), n then [ "linear_fib (5)", make_fib (C.linear 5), n
; "linear_fib (32)", make_fib (Cache.linear 32), n ; "linear_fib (32)", make_fib (C.linear 32), n
; "dummy_fib", make_fib Cache.dummy, n ; "dummy_fib", make_fib C.dummy, n
] @ l ] @ l
else l else l
in in