clj-commons / byte-streams

A Rosetta stone for JVM byte representations
417 stars 33 forks source link

Eagerly evaluate conversion paths? #10

Closed lynaghk closed 10 years ago

lynaghk commented 10 years ago

Is it possible to eagerly evaluate all of the conversion paths? I'm running into trouble with some time-sensitive core.async tests on my CI server because byte-streams lazily loads. E.g.

(time
  (bs/transfer (bs/to-byte-buffer "foo") (java.io.File/createTempFile "warm" "up")))
"Elapsed time: 1860.858 msecs"
"Elapsed time: 1.18 msecs"
ztellman commented 10 years ago

To be clear, do you want this to happen by default, or you just want a method you can call to eagerly evaluate everything in this special case? The latter seems okay.

lynaghk commented 10 years ago

A method would be fine, thanks.

ztellman commented 10 years ago

Okay, you can add this to your code in the short term:

(->> @@#'byte-streams/src->dst->conversion
  (mapcat #(map list (repeat %) (byte-streams/possible-conversions %)))
  distinct
  (map #(apply byte-streams/conversion-path %))
  dorun)