Skip to content

Instantly share code, notes, and snippets.

Morgen Peschke morgen-peschke

Block or report user

Report or block morgen-peschke

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@morgen-peschke
morgen-peschke / ExtensionMethodsOnCompanionObjects.scala
Created Mar 19, 2018
Example of how to create an Extension Method on a Companion Object
View ExtensionMethodsOnCompanionObjects.scala
object ExtensionMethodsOnCompanionObjects {
implicit class ListFactoryOps(val list: List.type) extends AnyVal {
def fizzbuzz(n: Int): List[String] =
(0 to n).map {
case n if n % 15 == 0 => "FizzBuzz"
case n if n % 3 == 0 => "Fizz"
case n if n % 5 == 0 => "Buzz"
case n => n.toString
}.toList
@morgen-peschke
morgen-peschke / junit-create-list-benchmark
Last active Aug 29, 2015
Java Create List Benchmark
View junit-create-list-benchmark
/* Results:
| Test Name | Time per round | Time in GC | Time in Benchmark |
|--------------------------------------------------+----------------+------------+-------------------|
| LinkedList Add only in front | 0.03 [+- 0.00] | 2.67 | 3.06 |
| LinkedList Add only in back | 0.03 [+- 0.01] | 2.61 | 3.01 |
| LinkedList Add in front and back | 0.03 [+- 0.00] | 2.66 | 3.16 |
| ArrayList Add only in front | 3.83 [+- 0.06] | 0.74 | 382.93 |
| ArrayList Add only in front with known size | 3.87 [+- 0.05] | 0.76 | 386.71 |
| ArrayList Add only in back | 0.01 [+- 0.01] | 0.69 | 0.87 |
| ArrayList Add only in back with known size | 0.01 [+- 0.01] | 0.76 | 0.93 |
You can’t perform that action at this time.