Find it here: https://github.com/bitemyapp/learnhaskell
This file contains 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
/* | |
* 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 |
This file contains 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.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; |
This file contains 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
(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 |
This file contains 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
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} |
This file contains 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
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; |
This file contains 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
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 | [ |
This file contains 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
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 | [ |
This file contains 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
package main | |
import ( | |
"io" | |
"os" | |
"time" | |
) | |
func singLine(line string,w io.Writer) { | |
time.Sleep(time.Second) |