Home | History | Annotate | Download | only in parser
      1 // Copyright 2012 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 parser
      6 
      7 import (
      8 	"go/token"
      9 	"io/ioutil"
     10 	"testing"
     11 )
     12 
     13 func BenchmarkParse(b *testing.B) {
     14 	src, err := ioutil.ReadFile("parser.go")
     15 	if err != nil {
     16 		b.Fatal(err)
     17 	}
     18 	b.ResetTimer()
     19 	b.SetBytes(int64(len(src)))
     20 	for i := 0; i < b.N; i++ {
     21 		if _, err := ParseFile(token.NewFileSet(), "", src, ParseComments); err != nil {
     22 			b.Fatalf("benchmark failed due to parse error: %s", err)
     23 		}
     24 	}
     25 }
     26