Skip to content

Instantly share code, notes, and snippets.

@alphazero
alphazero / bench-marker
Created January 26, 2012 02:05
micro benchmark for testing the concurrent queues
/*
* Copyright 2012 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
@alphazero
alphazero / bench-mark
Created January 26, 2012 04:04
A quick comp of pushing through a fixed number of items
This bench (for both o/c) is instantiating for each enqueue a new byte[1388] with a System.nanotime() call in array instantiation and assignment of b[0] = nanotime to insure the buffer creation is not inlined. (so numbers are more realistic).
[TOTAL] bytes:1778384896 - delta:97438 msec - bps:146670919 - wps:2291733 (1:1 LBQ)
[TOTAL] bytes:1778384896 - delta:72242 msec - bps:197598321 - wps:3087473 (1:1 CPQ)
@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
@alphazero
alphazero / incremental metrics - java1P-1C-1024b[]
Created January 29, 2012 04:53
Comparing 4 queues in a 1:1 Cons/Prod in tight loop for fairly long runs - incremental metrics and updated QItem gen
/*
Notes:
- Updated the qitem creation to pack byte[] with System.currentTimeMillis() as prep for latency tests.
- Also testing ConcurrentLinkedQueue (java.util.concurrent)
LBQ -> LinkedBlockingQueue [jdk]
CLQ -> ConcurrentLinkedQueue [jdk]
PCQ -> ConsumerProducerQueue [jacomecha]
@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}
rm -f _test/launchpad.net/gommap.a
6g -o _gotest_.6 gommap.go consts.go mmap_darwin_amd64.go
rm -f _test/launchpad.net/gommap.a
gopack grc _test/launchpad.net/gommap.a _gotest_.6
----------------------------------------------------------------------
FAIL: gommap_test.go:162: S.TestInCoreTwoPages
gommap_test.go:182:
c.Assert(mapped, Equals, []uint8{0, 1})
@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: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 / 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 / auto_throttle.go
Created April 7, 2012 17:28
auto-throttling an async fan-out
package main
import (
"log"
"runtime"
"time"
"math/rand"
)
func init() {