Skip to content

Commit

Permalink
Add benchmark for LexConfig
Browse files Browse the repository at this point in the history
Signed-off-by: Leandro López (inkel) <inkel.ar@gmail.com>
  • Loading branch information
inkel authored and apparentlymart committed Feb 15, 2022
1 parent 0ffd64d commit 73cd226
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions hclsyntax/public_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package hclsyntax

import (
"testing"

"github.com/hashicorp/hcl/v2"
)

func TestValidIdentifier(t *testing.T) {
Expand Down Expand Up @@ -44,3 +46,19 @@ func TestValidIdentifier(t *testing.T) {
})
}
}

var T Tokens

func BenchmarkLexConfig(b *testing.B) {
src := []byte("module \"once\" {\n source = \"../modules/foo\"\n}\n\nmodule \"twice\" {\n source = \"../modules/foo\"\n}\n")
filename := "testdata/dave/main.tf"
start := hcl.Pos{Line: 1, Column: 1, Byte: 0}

var tokens Tokens

for i := 0; i < b.N; i++ {
tokens, _ = LexConfig(src, filename, start)
}

T = tokens
}

0 comments on commit 73cd226

Please sign in to comment.