[info] benchmark ms linear runtime [info] NextIntJava 13.08 === [info] NextIntScala 13.07 === [info] NextIntLcg32 1.35 = [info] NextIntLcg64 1.32 = [info] NextIntBurtleRot2 1.37 = [info] NextIntBurtleRot3 1.46 = [info] NextIntCmwc5 1.35 = [info] NextIntWell512a 4.48 =
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
| val ms = Array("", "Fizz", "Buzz", "FizzBuzz") | |
| var acc = 810092048 | |
| var c = 0 | |
| val N = 50 | |
| (1 to N).foreach { i => | |
| c = acc & 3 | |
| println(if (c > 0) ms(c) else i) | |
| acc = acc >> 2 | c << 28 | |
| } |
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
| var finalhandler = require('finalhandler'); | |
| var http = require('http'); | |
| var morgan = require('morgan'); | |
| morgan.token('type', function (req, res) { | |
| return req.headers['content-type']; | |
| }); | |
| morgan.token('data', function (req, res) { | |
| return req.data; |
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
| import scala.util.Random | |
| object xorshift64star { | |
| private[this] var x: Long = { | |
| val x = Random.nextLong | |
| if (x == 0) -1 else x | |
| } | |
| def apply() = { | |
| x ^= x >>> 12 |
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
| use std::rc::Rc; | |
| pub enum FingerTree<A> { | |
| Empty, | |
| Single(A), | |
| Deep(Rc<Digit<A>>, Rc<FingerTree<Node<A>>>, Rc<Digit<A>>) | |
| } | |
| pub enum Digit<A> { | |
| One(A), |
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
| use std::iter::FromIterator; | |
| use std::rc::Rc; | |
| pub enum FingerTree<A> { | |
| Empty, | |
| Single(A), | |
| Deep(Rc<Digit<A>>, Rc<FingerTree<Node<A>>>, Rc<Digit<A>>) // TODO: the middle subtree should be lazily evaluated | |
| } | |
| use fingers::FingerTree::{Empty, Single, Deep}; |
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
| package benchmark | |
| import java.nio._ | |
| import java.util.concurrent.TimeUnit | |
| import org.openjdk.jmh.annotations._ | |
| object Random { | |
| def random = new scala.util.Random(0) | |
| def nextString(size: Int) = random.nextString(size) |
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
| type Foo[A] = A => Long => Int | |
| implicit def foo(s: String)(l: Long) = 3 | |
| implicitly[Foo[String]] // Works | |
| implicit def foo(s1: String, s2: String)(l: Long): Int = 3 | |
| implicitly[Foo[(String, String)]] // Doesn't work | |
| implicitly[(String, String) => Long => Int] // Works :-( | |
| implicit def foo(t: (String, String))(l: Long): Int = 3 |
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
| use std::rc::Rc; | |
| #[derive(Clone, Debug, Eq, PartialEq)] | |
| pub enum Color { | |
| Black, | |
| Red | |
| } | |
| use Color::{Black, Red}; |
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
| DUM 200 | |
| LDC 0 | |
| LDF 7 | |
| AP 1 | |
| LDF 18 | |
| RAP 200 | |
| RTN | |
| LDC 0 | |
| LD 0 0 | |
| LDC 199 |