summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Harris <git@peter.is-a-geek.org>2010-12-24 12:34:42 -0500
committerPeter Harris <git@peter.is-a-geek.org>2010-12-24 14:22:52 -0500
commit0ddd54a11b14525d77e0b9aa7fbe46ee704f85a3 (patch)
tree4293e426a19567695188f593846951167bd925ad
parent7a912d080a916cea77e302bcc150ddb2624a5d02 (diff)
Add simple noop test app
On my mac, x11perf does 13 million noop/sec This test app does 0.11 million noop/sec
-rw-r--r--.gitignore2
-rw-r--r--Makefile5
-rw-r--r--noop.go41
3 files changed, 45 insertions, 3 deletions
diff --git a/.gitignore b/.gitignore
index 5615d59..ab0e108 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,5 @@
test
+noop
build
*.6
-*.go
*.xcodeproj
diff --git a/Makefile b/Makefile
index d0866ae..d730151 100644
--- a/Makefile
+++ b/Makefile
@@ -9,8 +9,9 @@
%: %.6
6l -L. -o $@ $<
-# Compile our simple test app
-test: test.6
+# Compile our simple test apps
+all: test noop
# Dependencies
test.6: xgob.6
+noop.6: xgob.6
diff --git a/noop.go b/noop.go
new file mode 100644
index 0000000..43ae334
--- /dev/null
+++ b/noop.go
@@ -0,0 +1,41 @@
+package main
+
+import (
+ "flag"
+ "fmt"
+ "xgob"
+ )
+
+var iter *uint = flag.Uint("iter", 1000000, "Number of noops to send to the server")
+var wait *bool = flag.Bool("wait", false, "Wait for server to process noops")
+
+func main () {
+ flag.Parse()
+ c, _ := xgob.Connect("")
+
+ if c.HasError() {
+ println("Cannot open connection")
+ return
+ }
+
+ noopRequest := []byte{127, 0, 0, 1}
+
+ fmt.Printf("Sending %d noop requests: ", *iter)
+ for i := uint(0); i < *iter; i++ {
+ c.WriteNoreplyRequest(noopRequest)
+ }
+ c.Flush()
+ fmt.Println("Done.")
+
+ if *wait {
+ fmt.Print("Waiting for server: ")
+
+ gifRequest := []byte{43, 0, 0, 1}
+ cookie := c.WriteReplyRequest(gifRequest)
+
+ c.Flush()
+ <- cookie
+
+ fmt.Println("Done.")
+ }
+}