Skip to content

Instantly share code, notes, and snippets.

View tombentley's full-sized avatar

Tom Bentley tombentley

View GitHub Profile
I've got this Ceylon source:
```
class C() {
shared void m(String staticArg) {
print("Greeting: " + staticArg);
}
for (i in 0..1) {
m("");
}
@tombentley
tombentley / JDK5u22_client.log
Created November 30, 2012 10:55 — forked from rednaxelafx/JDK5u22_client.log
PrintCompilation samples running Groovy shell 1.7.7 on different versions of HotSpot VM
1 b java.lang.String::charAt (33 bytes)
2 b java.lang.Math::max (11 bytes)
3 b java.util.jar.Manifest$FastInputStream::readLine (167 bytes)
4 b sun.nio.cs.UTF_8$Decoder::decodeArrayLoop (553 bytes)
5 b java.util.Properties$LineReader::readLine (383 bytes)
6 b java.lang.String::hashCode (60 bytes)
7 b java.lang.String::indexOf (151 bytes)
8 b sun.nio.cs.ext.DoubleByteDecoder::decodeSingle (10 bytes)
9 b java.lang.String::lastIndexOf (156 bytes)
10 b java.lang.String::replace (142 bytes)
# If you want to allow filename that differ only by case set this variable to true.
allowcasecollision=$(git config hooks.allowcasecollision)
if [ "$allowcasecollision" != "true" ] &&
test "$(git diff --cached --name-only |
LC_ALL=C tr [A-Z] [a-z] |
sort |
uniq --repeated )"
then
echo "Error: Attempt to add a file name which differs only by case from "
@tombentley
tombentley / Array.ceylon
Last active August 29, 2015 14:02
This is the code I used to compare the different ways of sorting an Array
// This is the Array constructor I was testing. Note that if we can't create a primitive backing array we don't bother to copy the array again, we use the one we've already sorted.
private static <Element> java.lang.Object createArray(
final TypeDescriptor $reifiedElement,
ceylon.language.Iterable<? extends Element,?> elements,
final Callable<? extends Comparison> comparing) {
int size = Util.toInt(elements.getSize());
java.lang.Class<?> clazz = $reifiedElement.getArrayElementClass();
final java.lang.Object[] sortedArray;
if (comparing != null) {
Caused by: java.lang.RuntimeException: undecidable canonicalization
at com.redhat.ceylon.compiler.typechecker.model.ProducedType.resolveAliases(ProducedType.java:1772)
at com.redhat.ceylon.compiler.typechecker.model.ProducedType.curriedResolveAliases(ProducedType.java:1817)
at com.redhat.ceylon.compiler.typechecker.model.ProducedType.resolveAliases(ProducedType.java:1776)
at com.redhat.ceylon.compiler.typechecker.model.ProducedType.curriedResolveAliases(ProducedType.java:1817)
at com.redhat.ceylon.compiler.typechecker.model.ProducedType.resolveAliases(ProducedType.java:1776)
at com.redhat.ceylon.compiler.typechecker.model.ProducedType.curriedResolveAliases(ProducedType.java:1817)
at com.redhat.ceylon.compiler.typechecker.model.ProducedType.resolveAliases(ProducedType.java:1776)
at com.redhat.ceylon.compiler.typechecker.model.ProducedType.curriedResolveAliases(ProducedType.java:1817)
at com.redhat.ceylon.compiler.typechecker.model.ProducedType.resolveAliases(ProducedType.java:1776)
@tombentley
tombentley / benchmark.ceylon
Created June 13, 2014 11:06
Some benchmarking for optimized iteration depending on runtime type
import ceylon.language.meta{type}
Integer dynamicIterationBench({Integer*} iterable) {
variable value sum = 0;
for (int in iterable) {
sum += int;
}
return sum;
}
@tombentley
tombentley / pre-commit
Created June 18, 2014 13:28
lucaswerkmiester wanted the whole hook
#!/bin/sh
#
# An example hook script to verify what is about to be committed.
# Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
# To enable this hook, rename this file to "pre-commit".
if git rev-parse --verify HEAD >/dev/null 2>&1
@tombentley
tombentley / ConsTuple-sample-output.txt
Last active August 29, 2015 14:03
Are array-based Tuples better than linked list-based Tuples?
warmup
------
iteration
385.97869ms 100 size 1000000 iterations
4950000000
indexedAccess
7936.174072ms 100 size 1000000 iterations
4950000000
size=10, iterations=10000000
@tombentley
tombentley / TupleBench.ceylon
Created July 15, 2014 10:33
Some benchmark results comparing native Tuple with Ceylon tuple
import java.lang.management{ManagementFactory}
import ceylon.interop.java{CeylonIterable}
import java.lang{Runtime}
import java.util{Arrays}
class BenchmarkResult<out Result>(name, iterations, result, nanoseconds, memory) {
shared String name;
shared Integer iterations;
shared Result result;
shared Integer nanoseconds;

TO DO

  • SL = serialization library.
  • SC = SerializationContext
  • DC = DeserializationContext

SerializationContext.getReference()

Add method SerializationContext.getReference(Instance instance) to get the SerializableReference of an already registered instance: