Skip to content

Instantly share code, notes, and snippets.

View rklaehn's full-sized avatar

Rüdiger Klaehn rklaehn

  • Independent hacker
  • Transylvania, Romania
View GitHub Profile
@rklaehn
rklaehn / AstClient.java
Created February 19, 2014 10:15
Benchmark for inserting wide rows into a Cassandra DB using both CQL and Thrift APIs
package cassandra;
import java.util.Iterator;
import com.netflix.astyanax.ColumnListMutation;
import com.netflix.astyanax.serializers.AsciiSerializer;
import com.netflix.astyanax.serializers.LongSerializer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
// -Yno-predef
package collection
import scala.Predef.{???, println, implicitly}
trait Foreachable[T, U] {
def foreach(value: T, f: U Any): Unit
}
trait Indexable[T, U] {
def apply(value: T, index: Int): U
@rklaehn
rklaehn / Runner.java
Last active October 14, 2015 00:28
Flip random bits in an arbitrary process on a 64bit linux system. Works by reading in /proc/<pid>/mem and remote controlling gdb to do the actual writing.
public class Runner {
public static void main(String[] args) {
long[] data = new long[50000000];
int count=0;
while(true) {
long sum=0;
for(int i=0;i<data.length;i++)
sum+=data[i];
// if(count%20==0)
System.out.println(""+count+" "+sum);
rklaehn@rklaehn-hp:~/projects_git/satmon3$ sbt satmonjavaservices/dependencyTree
[info] Loading project definition from /home/rklaehn/projects_git/satmon3/project
[info] Set current project to satmon3 (in build file:/home/rklaehn/projects_git/satmon3/)
[info] heavens-above:satmonjavaservices_2.11:3.1.75_33302eb [S]
[info] +-com.google.protobuf:protobuf-java:2.5.0 (evicted by: 2.6.1)
[info] +-com.google.protobuf:protobuf-java:2.6.1
[info] +-com.jgoodies:jgoodies-looks:2.7.0
[info] | +-com.jgoodies:jgoodies-common:1.8.1
[info] |
[info] +-com.typesafe.akka:akka-actor_2.11:2.3.13 [S]
@rklaehn
rklaehn / ArrayBufferInsertBench.scala
Created December 13, 2014 11:23
Benchmark for SI-9043
import java.util
import ichi.bench.Thyme
import scala.collection.mutable.ArrayBuffer
object ArrayBufferInsertBench extends App {
val th = Thyme.warmed(verbose = println)
// val th = new Thyme()

Keybase proof

I hereby claim:

  • I am rklaehn on github.
  • I am rklaehn (https://keybase.io/rklaehn) on keybase.
  • I have a public key ASD7KkefWWOcjAZuq_IdyTzpXYnoZAdKoouzRSU_Ul25qwo

To claim this, I am signing this object:

@rklaehn
rklaehn / match.ts
Last active February 23, 2018 21:14
type Protocol = {
foo: { x: string };
bar: { y: number };
}
type Fold<T, U> = {
readonly [P in keyof T]: (value: T[P]) => U
}
type WithTag<T> = {
[TKey in keyof T]: { type: TKey } & T[TKey]
}
const enum Test { a = 'a' }
type Protocol = {
foo: { x: string };
bar: { y: number };
}
type WithTag<T> = {
[TKey in keyof T]: { type: TKey } & T[TKey]
}
type ToDiscriminatedUnion<P> = WithTag<P>[keyof P]
type Constructor<T> = {
@rklaehn
rklaehn / Results
Last active October 8, 2018 10:14
CBOR encoding performance
$ node benchmark2.js
= Encoding Time (ms) =
msgp.encode 9172.339491000399
borc.encode 20400.477496000007
json.stringify 9445.365290999413
= Decoding Time (ms) =
msgp.decode 121.99922000057995
borc.decodeFirst 383.22095499932766
json.parse 48.20755399949849
let msgpackLite = require('msgpack-lite');
let borc = require('borc');
let _ = require('lodash');
let { performance } = require('perf_hooks')
let arrays = _.times(100, (n) => {
return _.times(n, i => ({ i, a: [String(i * 1234), String(i * 1234), String(i * 1234), String(i * 1234)] }))
});
let encodedBORC = arrays.map(array => borc.encode(array));