Skip to content

Instantly share code, notes, and snippets.

@bitemyapp
bitemyapp / gist:8739525
Last active May 7, 2021 23:22
Learning Haskell
package main
import (
"io"
"os"
"time"
)
func singLine(line string,w io.Writer) {
time.Sleep(time.Second)
@alphazero
alphazero / gist:1838949
Created February 15, 2012 20:55
ComparativeBench run (favors Splays) Adds are 2048 rand key. Dels are random as well. starts with empty trees all.
delta(ns): 3851000 | [ADD] ops: 2048 | mods: 2047 | ops/sec: 531810 | mods/sec: 531550 | tot-size: 924342 [struct:TreeSet (JDK)]
delta(ns): 2507000 | [ADD] ops: 2048 | mods: 2045 | ops/sec: 816913 | mods/sec: 815716 | tot-size: 924516 [struct:STF<TreeSet>]
delta(ns): 5021000 | [ADD] ops: 2048 | mods: 2048 | ops/sec: 407887 | mods/sec: 407887 | tot-size: 924208 [struct:SplayTree]
delta(ns): 2453000 | [ADD] ops: 2048 | mods: 2047 | ops/sec: 834896 | mods/sec: 834488 | tot-size: 924401 [struct:STF<SplayTree>]
adding 2048 linear sequences of length: 1
delta(ns): 3404000 | [ADD] ops: 2048 | mods: 2047 | ops/sec: 601645 | mods/sec: 601351 | tot-size: 926389 [struct:TreeSet (JDK)]
delta(ns): 2557000 | [ADD] ops: 2048 | mods: 2046 | ops/sec: 800939 | mods/sec: 800156 | tot-size: 926562 [struct:STF<TreeSet>]
delta(ns): 5038000 | [ADD] ops: 2048 | mods: 2045 | ops/sec: 406511 | mods/sec: 405915 | tot-size: 926253 [struct:SplayTree]
delta(ns): 2555000 | [
@alphazero
alphazero / gist:1838879
Created February 15, 2012 20:43
ComparativeBench run (favors Splays) Adds are 20 linear sequences of 128 keys each, each starting with rand key. Dels are pure random
delta(ns): 781000 | [ADD] ops: 2560 | mods: 2560 | ops/sec: 3277849 | mods/sec: 3277849 | tot-size:2326408 [struct:TreeSet (JDK)]
delta(ns): 309000 | [ADD] ops: 2560 | mods: 2560 | ops/sec: 8284790 | mods/sec: 8284790 | tot-size:2326773 [struct:STF<TreeSet>]
delta(ns): 220000 | [ADD] ops: 2560 | mods: 2560 | ops/sec: 11636364 | mods/sec: 11636364 | tot-size:2327179 [struct:SplayTree]
delta(ns): 122000 | [ADD] ops: 2560 | mods: 2560 | ops/sec: 20983607 | mods/sec: 20983607 | tot-size:2327293 [struct:STF<SplayTree>]
adding 20 linear sequences of length: 128
delta(ns): 807000 | [ADD] ops: 2560 | mods: 2560 | ops/sec: 3172243 | mods/sec: 3172243 | tot-size:2328968 [struct:TreeSet (JDK)]
delta(ns): 307000 | [ADD] ops: 2560 | mods: 2560 | ops/sec: 8338762 | mods/sec: 8338762 | tot-size:2329333 [struct:STF<TreeSet>]
delta(ns): 229000 | [ADD] ops: 2560 | mods: 2560 | ops/sec: 11179039 | mods/sec: 11179039 | tot-size:2329739 [struct:SplayTree]
delta(ns): 119000 | [
@alphazero
alphazero / ComparativeBench.java
Created February 15, 2012 20:35
Comparative Bench of 4 search tree structures
package oss.alphazero.util.ds2.adhoctests;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import java.util.TreeSet;
import java.util.concurrent.ConcurrentSkipListSet;
import java.util.concurrent.TimeUnit;
import oss.alphazero.util.ds2.STF;
@alphazero
alphazero / gist:1697275
Created January 29, 2012 04:59
Summary - Comparing 4 queues in a 1:1 Cons/Prod in tight loop for fairly long runs - incremental metrics and updated QItem gen
Notes:
- See https://gist.github.com/1697257 for incremental metrics
- 1 Run only
[ TOTAL] bytes: 12500992000 | delta:115914855000 nsec | Bps: 107846333 | wps: 13480792 {LinkedBlockingQueue}
[ TOTAL] bytes: 12500992000 | delta:115579359000 nsec | Bps: 108159382 | wps: 13519923 {ConcurrentLinkedQueue}
[ TOTAL] bytes: 12500992000 | delta:117605985000 nsec | Bps: 106295543 | wps: 13286943 {ConsumerProducerQueue}
[ TOTAL] bytes: 12911008256 | delta: 8686817000 nsec | Bps: 1486276073 | wps: 185784509 {TcpQueueBase}
@alphazero
alphazero / (newenqueue).java1P-1C-1024b[](newenqueue).java
Created January 28, 2012 04:45
Comparing 3 queues in a 1:1 Cons/Prod in tight loop for fairly long runs
(newenqueue).java/*==========================================
LBQ -> LinkedBlockingQueue
PCQ -> ConsumerProducerQueue
TCPQ -> TCPQueueBase
Notes:
- benchmarks are notoriously difficult. your mileage /may/ vary
- load simulated here is that of a event based front-end dumping 1024 byte / enqueue
@jbrisbin
jbrisbin / DisruptorTest.java
Created December 30, 2011 17:22
Disruptor RingBuffer-based simplistic NIO HTTP test server
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.StandardSocketOptions;
import java.nio.ByteBuffer;
import java.nio.channels.CancelledKeyException;
import java.nio.channels.ReadableByteChannel;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.ServerSocketChannel;
/*
* Copyright 2010 Joubin Houshyar
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software