diff options
| author | Leandro López (inkel) <inkel.ar@gmail.com> | 2021-10-19 14:44:43 -0300 |
|---|---|---|
| committer | Martin Atkins <mart@degeneration.co.uk> | 2022-02-16 11:11:03 -0800 |
| commit | 3ce13e5ae5f90962342ee26d0c3c6f4daebf8f09 (patch) | |
| tree | 03a4ff5204788bdcab1a07f10b17469910d7a794 /hclsyntax/public_test.go | |
| parent | 0ffd64deae73e7bd14d0e8b1dbe9388d2e2e55c6 (diff) | |
hclsyntax: Add benchmark for LexConfig
Diffstat (limited to 'hclsyntax/public_test.go')
| -rw-r--r-- | hclsyntax/public_test.go | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/hclsyntax/public_test.go b/hclsyntax/public_test.go index 6280998..596b1a2 100644 --- a/hclsyntax/public_test.go +++ b/hclsyntax/public_test.go @@ -2,6 +2,8 @@ package hclsyntax import ( "testing" + + "github.com/hashicorp/hcl/v2" ) func TestValidIdentifier(t *testing.T) { @@ -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 +} |
