Last active
December 18, 2015 17:39
-
-
Save squito/5820138 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait ArraySummer[-T] { | |
def sum(t: T): Float | |
} | |
/** one TypeClass per concrete implementation */ | |
object SpecificSummers { | |
implicit object SimpleWrappedFloatArraySummer extends ArraySummer[SimpleWrappedFloatArray] { | |
def sum(arr: SimpleWrappedFloatArray): Float = { | |
... | |
} | |
} | |
implicit object FloatArrayAsBufferSummer extends ArraySummer[FloatArrayAsBuffer] { | |
def sum(arr: FloatArrayAsBuffer): Float = { | |
... | |
} | |
} | |
implicit object FloatArraySliceSummer extends ArraySummer[FloatArraySlice] { | |
def sum(arr: FloatArraySlice): Float = { | |
... | |
} | |
} | |
} | |
/** one TypeClass for all implementations of ArrayLike[Float] */ | |
object GenericSummers { | |
implicit object ArrayLikeSummer extends ArraySummer[ArrayLike[Float]] { | |
def sum(arr: ArrayLike[Float]): Float = { | |
... | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Gist for a blog post: http://imranrashid.com/posts/profiling-bytebuffers/
Full code is at https://github.com/squito/oleander/blob/blog_post_profiling_interfaces/src/test/scala/com/imranrashid/oleander/ByteBufferBackedTest.scala