本文整理汇总了Golang中expvar.Int类的典型用法代码### 示例。如果您正苦于以下问题:Golang Int类的具体用法?Golang Int怎么用?Golang Int使用的例子?那么恭喜您, 这里精选的类代码### 示例或许可以为您提供帮助。

在下文中一共展示了Int类的18个代码### 示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码### 示例。

示例1: Remove

func (l *WAL) Remove(files []string) error {
    l.mu.Lock()
    defer l.mu.Unlock()
    for _, fn := range files {
        os.RemoveAll(fn)
    }

    // Refresh the on-disk size stats
    segments, err := segmentFileNames(l.path)
    if err != nil {
        return err
    }

    var totalOldDiskSize int64
    for _, seg := range segments {
        stat, err := os.Stat(seg)
        if err != nil {
            return err
        }

        totalOldDiskSize += stat.Size()
    }
    sizeStat := new(expvar.Int)
    sizeStat.Set(totalOldDiskSize)
    l.statMap.Set(statWALOldBytes, sizeStat)

    return nil
}

开发者ID:seiflotfy,项目名称:influxdb,代码行数:28,代码来源:wal.go

示例2: recordSnapshot

func (g *goroutineTracker) recordSnapshot() {

    g.mutex.Lock()
    defer g.mutex.Unlock()

    // get number of goroutines
    numGoroutines := uint64(runtime.NumGoroutine())

    // bump the high water mark
    if numGoroutines > g.HighWaterMark {
        g.HighWaterMark = numGoroutines

        varInt := expvar.Int{}
        varInt.Set(int64(numGoroutines))
        base.StatsExpvars.Set("goroutines_highWaterMark", &varInt)
    }

    // append to history
    g.Snapshots = append(g.Snapshots, numGoroutines)

    // drop the oldest one if we've gone over the max
    if len(g.Snapshots) > kMaxGoroutineSnapshots {
        g.Snapshots = g.Snapshots[1:]
    }

}

开发者ID:paulharter,项目名称:sync_gateway,代码行数:26,代码来源:debug.go

示例3: UpdateAge

// Updates the age statistic
func (c *Cache) UpdateAge() {
    c.mu.RLock()
    defer c.mu.RUnlock()
    ageStat := new(expvar.Int)
    ageStat.Set(int64(time.Now().Sub(c.lastSnapshot) / time.Millisecond))
    c.statMap.Set(statCacheAgeMs, ageStat)
}

开发者ID:CowLeo,项目名称:influxdb,代码行数:8,代码来源:cache.go

示例4: writeSocketMetrics

func (e *Exporter) writeSocketMetrics(c net.Conn, f formatter, exportTotal *expvar.Int, exportSuccess *expvar.Int) error {
    e.store.RLock()
    defer e.store.RUnlock()

    for _, m := range e.store.Metrics {
        m.RLock()
        defer m.RUnlock()
        exportTotal.Add(1)
        lc := make(chan *metrics.LabelSet)
        go m.EmitLabelSets(lc)
        // This goroutine reads any bytes returned from the remote end, to keep
        // it unblocked.
        go func() {
            var buf bytes.Buffer
            for {
                _, err := buf.ReadFrom(c)
                if err == nil {
                    return
                }
            }
        }()
        for l := range lc {
            line := f(e.hostname, m, l)
            n, err := fmt.Fprint(c, line)
            glog.Infof("Sent %d bytes\n", n)
            if err == nil {
                exportSuccess.Add(1)
            } else {
                return fmt.Errorf("write error: %s\n", err)
            }
        }
    }
    return nil
}

开发者ID:nulleins0130,项目名称:mtail,代码行数:34,代码来源:export.go

示例5: determineProperties

func determineProperties(sizes []int) *expvar.Map {
    var sum int
    props := new(expvar.Map).Init()
    for _, n := range sizes {
        sum += n
    }
    // Determine properties
    sort.Ints(sizes)
    if len(sizes) > 0 {
        summary := map[string]int{
            "min":    sizes[0],
            "max":    sizes[len(sizes)-1],
            "length": len(sizes),
            "sum":    sum,
            "95e":    sizes[int(float64(len(sizes))*0.95)],
        }
        mean := float64(sum) / float64(summary["length"])

        // Pack them into an expvar Map
        for k, v := range summary {
            n := new(expvar.Int)
            n.Set(int64(v))
            props.Set(k, n)
        }
        avge := new(expvar.Float)
        avge.Set(mean)
        props.Set("avg", avge)
    }

    return props
}

开发者ID:jessereynolds,项目名称:coco,代码行数:31,代码来源:coco.go

最后编辑: kuteng  文档更新时间: 2021-08-23 19:14   作者:kuteng