1
0
mirror of https://github.com/golang/go synced 2024-11-06 04:26:11 -07:00
Commit Graph

16 Commits

Author SHA1 Message Date
Bryan C. Mills
7e036521d5 expvar: add benchmark for (*Map).Set with per-goroutine keys
Change-Id: I0fa68ca9812fe5e82ffb9d0b9598e95b47183eb8
Reviewed-on: https://go-review.googlesource.com/38011
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-03-10 19:09:48 +00:00
Bryan C. Mills
7ffdb75775 expvar: add benchmarks for steady-state Map Add calls
Add a benchmark for setting a String value, which we may
want to treat differently from Int or Float due to the need to support
Add methods for the latter.

Update tests to use only the exported API instead of making (fragile)
assumptions about unexported fields.

The existing Map benchmarks construct a new Map for each iteration, which
focuses the benchmark results on the initial allocation costs for the
Map and its entries. This change adds variants of the benchmarks which
use a long-lived map in order to measure steady-state performance for
Map updates on existing keys.

Updates #18177

Change-Id: I62c920991d17d5898c592446af382cd5c04c528a
Reviewed-on: https://go-review.googlesource.com/36959
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-02-14 22:11:35 +00:00
Bryan C. Mills
aa15387996 expvar: make BenchmarkAdd{Same,Different} comparable to 1.8
bradfitz noted in change 36717 that the new behavior was no longer
comparable with the old.  This change restores comparable behavior
for -cpu=1.

BenchmarkMapAddSame                 909           909           +0.00%
BenchmarkMapAddSame-6               1309          262           -79.98%
BenchmarkMapAddDifferent            2856          3030          +6.09%
BenchmarkMapAddDifferent-6          3803          581           -84.72%

updates #18177

Change-Id: Ifaff5a1f48be92002d86c296220313b7efdc81d6
Reviewed-on: https://go-review.googlesource.com/36723
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-02-10 20:08:14 +00:00
Bryan C. Mills
39651bb50b expvar: parallelize BenchmarkMapAdd{Same,Different}
The other expvar tests are already parallelized, and this will help to
measure the impact of potential implementations for #18177.

updates #18177

Change-Id: I0f4f1a16a0285556cbcc8339855b6459af412675
Reviewed-on: https://go-review.googlesource.com/36717
Reviewed-by: Russ Cox <rsc@golang.org>
2017-02-10 17:37:14 +00:00
Filippo Valsorda
714318be88 expvar: add Value methods
Closes #15815

Change-Id: I08154dbff416198cf7787e446b1e00e62c03a972
Reviewed-on: https://go-review.googlesource.com/30917
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-13 21:39:03 +00:00
Anders Pearson
6ba5b32922 expvar: export http.Handler
Add a method to expose the handler to allow it to be installed at a
non-standard location or used with a different ServeMux.

fixes #15030

Change-Id: If778ad6fcc200f124a05c0a493511e364fca6078
Reviewed-on: https://go-review.googlesource.com/24722
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-09-25 23:34:28 +00:00
Scott Bell
2a12035f8e expvar: slightly expand documentation for Var's String method
Fixes #15088.

Change-Id: I7727829a4062e15c0e5e3beff4d0bfc1fa327b0f
Reviewed-on: https://go-review.googlesource.com/23232
Reviewed-by: Andrew Gerrand <adg@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-05-19 04:20:47 +00:00
David Symonds
6f2a8810b0 expvar: Ensure strings are written as valid JSON.
Change-Id: I5147dbf4e85cf42cd1f32c57861e4c16d9dbd049
Reviewed-on: https://go-review.googlesource.com/21529
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-04-06 03:52:39 +00:00
David Symonds
e8f01e5cae expvar: document that the Var interface's String method should return a valid JSON value.
Change-Id: If4e740f3dbef4053355542eebdd899b3099d872c
Reviewed-on: https://go-review.googlesource.com/21525
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-04-05 05:50:56 +00:00
Brad Fitzpatrick
5fea2ccc77 all: single space after period.
The tree's pretty inconsistent about single space vs double space
after a period in documentation. Make it consistently a single space,
per earlier decisions. This means contributors won't be confused by
misleading precedence.

This CL doesn't use go/doc to parse. It only addresses // comments.
It was generated with:

$ perl -i -npe 's,^(\s*// .+[a-z]\.)  +([A-Z]),$1 $2,' $(git grep -l -E '^\s*//(.+\.)  +([A-Z])')
$ go test go/doc -update

Change-Id: Iccdb99c37c797ef1f804a94b22ba5ee4b500c4f7
Reviewed-on: https://go-review.googlesource.com/20022
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Dave Day <djd@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-02 00:13:47 +00:00
Rick Arnold
5abd327d00 expvar: document that Get returns nil for non-existent vars
Also added a test to ensure the behavior.

Fixes #14150

Change-Id: Ib3ee9fdae59826fa594ce1be3c49b51d740b56eb
Reviewed-on: https://go-review.googlesource.com/19915
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-25 16:48:08 +00:00
Matt T. Proud
926616da3f expvar: swap Float sync. from mutex to atomic.
Float type from a mutex to atomic bit array in a manner akin to
Google Guava's AtomicDouble[0], including adding a benchmark for the
type (benchcmp included below) along with some expvar_test.go cruft
being fixed.

benchmark             old ns/op     new ns/op     delta
BenchmarkFloatSet     115           9.37          -91.85%
BenchmarkFloatAdd     114           17.1          -85.00%

benchmark             old allocs     new allocs     delta
BenchmarkFloatSet     0              0              +0.00%
BenchmarkFloatAdd     0              0              +0.00%

benchmark             old bytes     new bytes     delta
BenchmarkFloatSet     0             0             +0.00%
BenchmarkFloatAdd     0             0             +0.00%

[0] - http://goo.gl/m4dtlI

Change-Id: I4ce6a913734ec692e3ed243f6e6f7c11da4c6036
Reviewed-on: https://go-review.googlesource.com/3687
Reviewed-by: Rob Pike <r@golang.org>
2015-04-12 23:07:50 +00:00
Dmitry Vyukov
08ca401444 expvar: fix build
Change-Id: I6ee7aa76673e51576b5a84c512b22a0f8af5b02f
Reviewed-on: https://go-review.googlesource.com/3966
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
2015-02-05 13:53:29 +00:00
Evan Phoenix
fc22fb8f0c expvar: Add benchmarks for perf sensitive operations
These benchmarks are only for functions commonly used in loops. The
other functions are typically used for inspection or setup and thus are
not performance sensitive.

Change-Id: I8d0a0ba2d8234ecacb40fa3aa9077bf93c8fe89c
Reviewed-on: https://go-review.googlesource.com/3680
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
2015-02-05 13:32:25 +00:00
Evan Phoenix
bd043d8629 expvar: Use sync/atomic to manipulate Int for better perf
Using a mutex to protect a single int operation is quite heavyweight.
Using sync/atomic provides much better performance. This change was
benchmarked as such:

BenchmarkSync   10000000       139 ns/op
BenchmarkAtomic 200000000      9.90 ns/op

package blah

import (
        "sync"
        "sync/atomic"
        "testing"
)

type Int struct {
        mu sync.RWMutex
        i  int64
}

func (v *Int) Add(delta int64) {
        v.mu.Lock()
        defer v.mu.Unlock()
        v.i += delta
}

type AtomicInt struct {
        i int64
}

func (v *AtomicInt) Add(delta int64) {
        atomic.AddInt64(&v.i, delta)
}

func BenchmarkSync(b *testing.B) {
        s := new(Int)

        for i := 0; i < b.N; i++ {
                s.Add(1)
        }
}

func BenchmarkAtomic(b *testing.B) {
        s := new(AtomicInt)

        for i := 0; i < b.N; i++ {
                s.Add(1)
        }
}

Change-Id: I6998239c785967647351bbfe8533c38e4894543b
Reviewed-on: https://go-review.googlesource.com/3430
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
2015-01-29 08:24:00 +00:00
Russ Cox
c007ce824d build: move package sources from src/pkg to src
Preparation was in CL 134570043.
This CL contains only the effect of 'hg mv src/pkg/* src'.
For more about the move, see golang.org/s/go14nopkg.
2014-09-08 00:08:51 -04:00