github.com/TeaOSLab/EdgeNode@v1.3.8/internal/trackers/manager_test.go (about)

     1  // Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
     2  
     3  package trackers_test
     4  
     5  import (
     6  	"github.com/TeaOSLab/EdgeNode/internal/trackers"
     7  	"github.com/iwind/TeaGo/logs"
     8  	"testing"
     9  	"time"
    10  )
    11  
    12  func TestNewManager(t *testing.T) {
    13  	{
    14  		var tr = trackers.Begin("a")
    15  		tr.End()
    16  	}
    17  	{
    18  		var tr = trackers.Begin("a")
    19  		time.Sleep(1 * time.Millisecond)
    20  		tr.End()
    21  	}
    22  	{
    23  		var tr = trackers.Begin("a")
    24  		time.Sleep(2 * time.Millisecond)
    25  		tr.End()
    26  	}
    27  	{
    28  		var tr = trackers.Begin("a")
    29  		time.Sleep(3 * time.Millisecond)
    30  		tr.End()
    31  	}
    32  	{
    33  		var tr = trackers.Begin("a")
    34  		time.Sleep(4 * time.Millisecond)
    35  		tr.End()
    36  	}
    37  	{
    38  		var tr = trackers.Begin("a")
    39  		time.Sleep(5 * time.Millisecond)
    40  		tr.End()
    41  	}
    42  	{
    43  		var tr = trackers.Begin("b")
    44  		tr.End()
    45  	}
    46  
    47  	logs.PrintAsJSON(trackers.SharedManager.Labels(), t)
    48  }
    49  
    50  func TestTrackers_Add(t *testing.T) {
    51  	var tr = trackers.Begin("a")
    52  	time.Sleep(50 * time.Millisecond)
    53  	tr.Add(-10 * time.Millisecond)
    54  	tr.End()
    55  	t.Log(trackers.SharedManager.Labels())
    56  }