Skip to content

Commit

Permalink
timing (squash me. should use %bench)
Browse files Browse the repository at this point in the history
  • Loading branch information
oxinabox committed Dec 15, 2020
1 parent 9738530 commit 5641b5f
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions examples/hashmap.dx
Original file line number Diff line number Diff line change
Expand Up @@ -179,18 +179,22 @@ def tryGetHashDict (_:Hashable k) ?=> (dict:HashDict k v) (key:k) : Maybe v =
' Benchmarking
https://github.com/google-research/dex-lang/issues/341

full_data = for i:(Fin 128). ([10 * ordinal i, ordinal i], i)
full_data = for i:(Fin 256). ([10 * ordinal i, ordinal i], i)

big_listdict = fold (emptyListDict _ _) \i state. storeListDict state (fst full_data.i) (snd full_data.i)


big_hashdict = fold (emptyHashDict 64 _ _) \i state. storeHashDict state (fst full_data.i) (snd full_data.i)
big_hashdict = fold (emptyHashDict 128 _ _) \i state. storeHashDict state (fst full_data.i) (snd full_data.i)

%time
tryGetHashDict big_hashdict [1280, 128]

%time
tryGetListDict big_listdict [1280, 128]

%time
thehash [1280, 128]

:p tryGetHashDict big_hashdict [210, 21]
:p tryGetListDict big_listdict [210, 21]
:p tryGetHashDict big_hashdict [210, 20]
:p tryGetListDict big_listdict [210, 20]

' ## Wrap under a common interface
See how annoying above was without a common interface that i could just pass in the initial value (with its type) and have it work out which store to read etc
Expand Down

0 comments on commit 5641b5f

Please sign in to comment.