Skip to content

lennon-guan/gtimer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gtimer - An easy way to test time cost in golang

简体中文

Example:

// gtimer_test.go

func testFunc() {
	gtimer.Tick("enter testFunc")
	time.Sleep(150 * time.Millisecond)
	gtimer.Tick("exit testFunc")
}

func TestTimer(t *testing.T) {
	defer gtimer.Start("test1").End()
	time.Sleep(100 * time.Millisecond)
	testFunc()
	time.Sleep(50 * time.Millisecond)
}

/* Output:
Time cost for topic 'test1' total 302.772167ms: 
  |- [begin-enter testFunc]: 101.1695ms
  |- [enter testFunc-exit testFunc]: 151.044334ms
  |- [exit testFunc-end]: 50.558333ms
*/

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages