MCPcopy
hub / github.com/tsenart/vegeta / TestPlot

Function TestPlot

lib/plot/plot_test.go:21–67  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

19var update = flag.Bool("update", false, "Update .golden files")
20
21func TestPlot(t *testing.T) {
22 p := New(Title("TestPlot"), Downsample(400))
23
24 rng := rand.New(rand.NewSource(0))
25 zf := rand.NewZipf(rng, 3, 2, 1000)
26 attacks := []string{"500QPS", "1000QPS", "2000QPS"}
27 began := time.Now()
28 for i := 0; i < 1e5; i++ {
29 for _, attack := range attacks {
30 r := vegeta.Result{
31 Attack: attack,
32 Seq: uint64(i),
33 Timestamp: began.Add(time.Duration(i) * time.Millisecond),
34 Latency: time.Duration(zf.Uint64()) * time.Millisecond,
35 }
36
37 if err := p.Add(&r); err != nil {
38 t.Fatal(err)
39 }
40 }
41 }
42
43 p.Close()
44
45 var b bytes.Buffer
46 if _, err := p.WriteTo(&b); err != nil {
47 t.Fatal(err)
48 }
49
50 gp := filepath.Join("testdata", filepath.FromSlash(t.Name())+".golden.html")
51 if *update {
52 t.Logf("updating %q", gp)
53 if err := os.WriteFile(gp, b.Bytes(), 0644); err != nil {
54 t.Fatalf("failed to update %q: %s", gp, err)
55 }
56 }
57
58 g, err := os.ReadFile(gp)
59 if err != nil {
60 t.Fatalf("failed reading %q: %s", gp, err)
61 }
62
63 if !bytes.Equal(b.Bytes(), g) {
64 t.Log(b.String())
65 t.Errorf("bytes do not match %q", gp)
66 }
67}
68
69func TestLabeledSeries(t *testing.T) {
70 t.Parallel()

Callers

nothing calls this directly

Calls 8

NewFunction · 0.85
TitleFunction · 0.85
WriteToMethod · 0.80
DownsampleFunction · 0.70
AddMethod · 0.65
CloseMethod · 0.65
EqualMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected