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
type Buffer struct { | |
buf []byte // contents are the bytes buf[off : len(buf)] | |
off int // read at &buf[off], write at &buf[len(buf)] | |
runeBytes [utf8.UTFMax]byte // avoid allocation of slice on each WriteByte or Rune | |
bootstrap [64]byte // memory to hold first slice; helps small buffers avoid allocation. | |
lastRead readOp // last read operation, so that Unread* can work correctly. | |
} |
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
(pprof) list varint.VarintEncode | |
5.89s 26.37s (flat, cum) 39.97% of Total | |
. . 40:// | |
190ms 190ms 41:func VarintEncode(w io.Writer, v uint64) error { | |
230ms 4.35s 42: ba := [1]byte{} | |
410ms 410ms 43: nexp := 0 | |
. . 44: ntot := 0 | |
210ms 210ms 45: for (v & 0xFFFFFFFFFFFFFF80) != 0 { | |
280ms 280ms 46: ba[0] = byte((v & 0x7F) | 0x80) | |
-> 2.51s 15.19s 47: n, _ := w.Write(ba[:]) |
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
func ReadVarIntToUint(r io.Reader) (uint64, error) { | |
var ( | |
varbs []byte | |
ba [1]byte | |
u uint64 | |
n int | |
err error | |
) | |
varbs = make([]byte, 0, 10) |
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
(pprof) list binary.Read | |
Total: 4.27mins | |
5.02s 25.50s (flat, cum) 9.96% of Total | |
. . 137:// When reading into a struct, all non-blank fields must be exported. | |
330ms 330ms 138:func Read(r io.Reader, order ByteOrder, data interface{}) error { | |
. . 139: // Fast path for basic types and slices. | |
430ms 2.85s 140: if n := intDataSize(data); n != 0 { | |
240ms 6.85s 141: var b [8]byte | |
130ms 130ms 142: var bs []byte | |
20ms 20ms 143: if n > len(b) { |
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
func VarintEncode(w io.Writer, v uint64) error { | |
bs := make([]byte, 0, 10) | |
for (v & 0xffffffffffffff80) != 0 { | |
bs = append(bs, byte((v&0x7f)|0x80)) | |
v >>= 7 | |
} | |
bs = append(bs, byte(v&0x7f)) | |
n, err := w.Write(bs) |
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
(pprof) list varint.ReadVarIntToUint | |
Total: 4.27mins | |
ROUTINE ======================== g/q/o/o/b/varint.ReadVarIntToUint | |
19.20s 1.86mins (flat, cum) 43.51% of Total | |
370ms 370ms 60:func ReadVarIntToUint(r io.Reader) (uint64, error) { | |
. . 61: var ( | |
130ms 130ms 62: varbs []byte | |
230ms 4.65s 63: ba [1]byte | |
190ms 6.51s 64: u uint64 | |
. . 65: n int |
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
type testrange struct { | |
start int64 | |
end int64 | |
} | |
func zigzagExhaustiveTest() { | |
runtime.GOMAXPROCS(8) | |
var wg sync.WaitGroup |
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 quux00.curator; | |
import java.util.List; | |
import org.apache.curator.framework.CuratorFramework; | |
import org.apache.curator.framework.recipes.locks.LockInternalsDriver; | |
import org.apache.curator.framework.recipes.locks.PredicateResults; | |
import org.apache.zookeeper.CreateMode; | |
import org.apache.zookeeper.KeeperException; |
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 quux00.curator; | |
import java.util.Collection; | |
import java.util.Iterator; | |
import java.util.UUID; | |
import java.util.concurrent.TimeUnit; | |
import org.apache.curator.RetryPolicy; | |
import org.apache.curator.framework.CuratorFramework; | |
import org.apache.curator.framework.CuratorFrameworkFactory; |
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
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>mechsympathy</groupId> | |
<artifactId>mechsympathy</artifactId> | |
<packaging>jar</packaging> | |
<version>1.0-SNAPSHOT</version> | |
<name>mechsympathy</name> | |
<url>http://maven.apache.org</url> |
NewerOlder