2021-07-30 17:53:27 +00:00
|
|
|
package php8_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io/ioutil"
|
2023-03-25 13:32:14 +00:00
|
|
|
"path/filepath"
|
2021-07-30 17:53:27 +00:00
|
|
|
"testing"
|
|
|
|
|
2023-12-09 21:36:19 +00:00
|
|
|
"git.maride.cc/maride/php-parser/internal/php8"
|
|
|
|
"git.maride.cc/maride/php-parser/pkg/conf"
|
|
|
|
"git.maride.cc/maride/php-parser/pkg/version"
|
2021-07-30 17:53:27 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func BenchmarkPhp8(b *testing.B) {
|
2023-03-25 13:32:14 +00:00
|
|
|
src, err := ioutil.ReadFile(filepath.Join("testdata", "test.php"))
|
2021-07-30 17:53:27 +00:00
|
|
|
if err != nil {
|
2023-03-25 13:32:14 +00:00
|
|
|
b.Fatal("can not read testdata/test.php: " + err.Error())
|
2021-07-30 17:53:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for n := 0; n < b.N; n++ {
|
|
|
|
config := conf.Config{
|
|
|
|
Version: &version.Version{
|
|
|
|
Major: 8,
|
|
|
|
Minor: 8,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
lexer := php8.NewLexer(src, config)
|
|
|
|
php8parser := php8.NewParser(lexer, config)
|
|
|
|
php8parser.Parse()
|
|
|
|
}
|
|
|
|
}
|