This file contains hidden or 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 os, streams, parsexml, strutils | |
| if paramCount() < 1: | |
| quit("Usage: parse filename[.xml]") | |
| var filename = addfileExt(paramStr(1), "xml") | |
| var s = newFileStream(filename, fmRead) | |
| if s == nil: quit("Cannot open the file" & filename) | |
| var x: XmlParser | |
| open(x, s, filename) |
This file contains hidden or 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
| actor: | |
| function function_ref: | |
| commands: | |
| command "FRONTEND": | |
| stuff ... | |
| command "PAUSE": | |
| stuff ... | |
| command "RESUME: | |
| stuff ... |
This file contains hidden or 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 czmq | |
| var pull = zsock_new(ZMQ_PULL) | |
| var rc = zsock_connect(pull, "inproc://zsock_test") | |
| var push = zsock_new(ZMQ_PUSH) | |
| rc = zsock_bind(push, "inproc://zsock_test") | |
| for i in countdown(100000000, 1): |
This file contains hidden or 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
| BenchmarkSetGetMutex 2000000 668 ns/op |
This file contains hidden or 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
| go test -bench=. | |
| testing: warning: no tests to run | |
| PASS | |
| BenchmarkSetGet 2000000000 0.61 ns/op | |
| BenchmarkSetGetMutex 10000000 119 ns/op | |
| ok github.com/taotetek/mutextest 2.622s |
This file contains hidden or 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 goczmq | |
| import ( | |
| "sync" | |
| "testing" | |
| ) | |
| // WITHOUT MUTEX | |
| type WithoutMutex struct { |
This file contains hidden or 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 ( | |
| "encoding/gob" | |
| "fmt" | |
| "github.com/zeromq/goczmq" | |
| ) | |
| // person is an example type we will encode, send, and decode |
This file contains hidden or 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 benchmarkChanneler(size int, b *testing.B) { | |
| pullSock := NewSock(Pull) | |
| pullSock.Bind("inproc://benchChan") | |
| defer pullSock.Destroy() | |
| channeler := NewChanneler(pullSock, false) | |
| time.Sleep(10 * time.Millisecond) | |
| go func() { | |
| pushSock := NewSock(Push) |
This file contains hidden or 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 benchmarkLogtalez(size int, b *testing.B) { | |
| endpoints := []string{"inproc://benchmark"} | |
| topics := []string{""} | |
| servercert := "./example_certs/example_curve_server_cert" | |
| clientcert := "./example_certs/example_curve_client_cert" | |
| go func() { | |
| lt, err := New(endpoints, topics, servercert, clientcert) | |
| if err != nil { | |
| panic(err) |
This file contains hidden or 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 goczmq | |
| import ( | |
| "fmt" | |
| ) | |
| func ExampleTraditionalRequestResponder() { | |
| go func() { | |
| responder := NewSock(Rep) | |
| _, err := responder.Bind("inproc://traditional") |