Git Product home page Git Product logo

statsdbench's Introduction

Benchmark of my StatsD client with the Go clients listed on the StatsD wiki:

$ go test -bench . -benchmem -benchtime=5s
BenchmarkAlexcesaro-4    5000000     1277 ns/op      0 B/op     0 allocs/op
BenchmarkCactus-4        2000000     3301 ns/op      4 B/op     0 allocs/op
BenchmarkG2s-4            200000    38715 ns/op    624 B/op    26 allocs/op
BenchmarkQuipo-4         2000000     4887 ns/op    496 B/op    10 allocs/op

statsdbench's People

Contributors

alexcesaro avatar

Stargazers

 avatar  avatar

Watchers

 avatar

statsdbench's Issues

udp server not being used?

#1. Fix destination address

The const addr is being used as the destination address for the test clients. It seems the intent was for this address to send to the server instance that is started earlier in the benchmarks.

c, err := cactus.NewBufferedClient(addr, prefix, flushPeriod, 1432)

This should instead probably be...

c, err := cactus.NewBufferedClient(s.conn.LocalAddr().String(), prefix, flushPeriod, 1432)

#2. Reset timers so setup is not counted as part of benchmarks.

func BenchmarkCactus(b *testing.B) {
    s := newServer()
    c, err := cactus.NewBufferedClient(s.conn.LocalAddr().String(), prefix, flushPeriod, 1432)
    if err != nil {
        b.Fatal(err)
    }
    b.ResetTimer()  ## <== this is the key here. this reset the counters and timers,
                    ##     so only the following lines are counted.

    for i := 0; i < b.N; i++ {
        c.Inc(counterKey, 1, 1)
        c.Gauge(gaugeKey, gaugeValue, 1)
        c.Timing(timingKey, int64(timingValue), 1)
    }
    c.Close()
    s.Close()
}

The two above changes should help the clients uniformly (at the very least #2 will).

timingValue - int vs. time.Duration

It seems to me the current code gives a misleading benchmark, since the Timing() method of the alexcesaro client takes in interface{} as its value - which is passed all the way down to appendNumber(), but since it's not a numeric it's not appended at all.

So calls to
func (c *Client) Timing(bucket string, value interface{})
should take something which appendNumber can recognizes. But not a time.Duration.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.