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.collection._ | |
import scala.collection.generic._ | |
import scala.collection.mutable.Builder | |
trait ManagedResource[+A] { self => | |
def acquireFor[R](f: A => R): R | |
def map[B](g: A => B): ManagedResource[B] = new ManagedResource[B] { | |
override def acquireFor[R](f: B => R) = { | |
self.acquireFor(x => f(g(x))) |
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 java.io._ | |
import java.nio._ | |
val f = new File("/dev/zero") | |
val size = 10000 | |
val count = 100000 | |
def readUsingInputStream() { | |
val is = new FileInputStream(f) |
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
def profile[T](what: String)(action: => T) = { | |
val start = System.currentTimeMillis() | |
val r = action | |
val delta = System.currentTimeMillis() - start | |
println(what + ": " + delta + "; " + r) | |
} |
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
case class A(value: Int) | |
def sort(a: java.util.List[A]) = { | |
val c = new java.util.Comparator[A] { | |
override def compare(x: A, y: A) = x.value - y.value | |
} | |
java.util.Collections.sort(a, c) | |
} | |
def profile[T](what: String)(action: => T) = { |
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
#include <sys/time.h> | |
#include <time.h> | |
#include <stdlib.h> | |
#include <vector> | |
#include <iostream> | |
#include <algorithm> | |
using namespace std; |
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
def sort(a: Array[Int]) = { | |
java.util.Arrays.sort(a) | |
} | |
def profile[T](what: String)(action: => T) = { | |
val start = System.currentTimeMillis() | |
val r = action | |
val delta = System.currentTimeMillis() - start | |
println(what + ": " + delta + "; " + r) | |
} |
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
<target name="getjar-helper2" unless="skip.download"> | |
<echo>Getting ${url} to ${file}</echo> | |
</target> | |
<target name="getjar-helper"> | |
<available property="skip.download" file="${file}"/> | |
<antcall target="getjar-helper2"/> | |
</target> | |
<macrodef name="getjar"> |
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
Index: build.xml | |
=================================================================== | |
--- build.xml (revision 20173) | |
+++ build.xml (working copy) | |
@@ -5,6 +5,47 @@ | |
<description> | |
SuperSabbus for Scala core, builds the scala library and compiler. It can also package it as a simple distribution, tests it for stable bootstrapping and against the Scala test suite. | |
</description> | |
+ | |
+ <target name="getjar-helper2" unless="skip.download"> |
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 java.util.*; | |
class Main { | |
private static final Random random = new Random(); | |
static class A { | |
} /// end of A | |
static class B { | |
private final int hashCode = random.nextInt(); |
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
#include <stdio.h> | |
#include <sys/time.h> | |
#include <stdlib.h> | |
#include <stdint.h> | |
const uint64_t count = 1000 * 1000 * 1000; | |
static uint64_t microseconds() { | |
struct timeval tv; | |
if (0 != gettimeofday(&tv, NULL)) |