File: main.go

package info (click to toggle)
golang-github-performancecopilot-speed 4.0.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 508 kB
  • sloc: makefile: 38
file content (44 lines) | stat: -rw-r--r-- 791 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package main

import (
	"flag"
	"fmt"
	"log"
	"time"

	"github.com/performancecopilot/speed/v4"
)

var timelimit = flag.Int("time", 60, "number of seconds to run for")

func main() {
	flag.Parse()

	metric, err := speed.NewPCPCounter(
		0,
		"counter",
		"A Simple Metric",
	)
	if err != nil {
		log.Fatal("Could not create counter, error: ", err)
	}

	client, err := speed.NewPCPClient("singletoncounter")
	if err != nil {
		log.Fatal("Could not create client, error: ", err)
	}

	err = client.Register(metric)
	if err != nil {
		log.Fatal("Could not register metric, error: ", err)
	}

	client.MustStart()
	defer client.MustStop()

	fmt.Println("The metric should be visible as mmv.singletoncounter.counter")
	for i := 0; i < *timelimit; i++ {
		metric.Up()
		time.Sleep(time.Second)
	}
}