Source file test/bench/go1/time_test.go

     1  // Copyright 2013 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package go1
     6  
     7  // benchmark based on time/time_test.go
     8  
     9  import (
    10  	"testing"
    11  	"time"
    12  )
    13  
    14  func BenchmarkTimeParse(b *testing.B) {
    15  	for i := 0; i < b.N; i++ {
    16  		time.Parse(time.ANSIC, "Mon Jan  2 15:04:05 2006")
    17  	}
    18  }
    19  
    20  func BenchmarkTimeFormat(b *testing.B) {
    21  	t := time.Unix(1265346057, 0)
    22  	for i := 0; i < b.N; i++ {
    23  		t.Format("Mon Jan  2 15:04:05 2006")
    24  	}
    25  }
    26  

View as plain text