Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 1 of 1 for doOnceFunc (0.4 sec)

  1. src/sync/oncefunc_test.go

    var (
    	onceFunc = sync.OnceFunc(func() {})
    
    	onceFuncOnce sync.Once
    )
    
    func doOnceFunc() {
    	onceFuncOnce.Do(func() {})
    }
    
    func BenchmarkOnceFunc(b *testing.B) {
    	b.Run("v=Once", func(b *testing.B) {
    		b.ReportAllocs()
    		for i := 0; i < b.N; i++ {
    			// The baseline is direct use of sync.Once.
    			doOnceFunc()
    		}
    	})
    	b.Run("v=Global", func(b *testing.B) {
    		b.ReportAllocs()
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Nov 21 17:31:33 UTC 2023
    - 6.9K bytes
    - Viewed (0)
Back to top