2018-02-18 12:25:20 +00:00
|
|
|
package php7_test
|
|
|
|
|
|
|
|
import (
|
2020-12-20 09:38:13 +00:00
|
|
|
"io/ioutil"
|
2023-03-25 13:32:14 +00:00
|
|
|
"path/filepath"
|
2018-02-18 12:25:20 +00:00
|
|
|
"testing"
|
|
|
|
|
2023-12-09 21:36:19 +00:00
|
|
|
"git.maride.cc/maride/php-parser/internal/php7"
|
|
|
|
"git.maride.cc/maride/php-parser/pkg/conf"
|
|
|
|
"git.maride.cc/maride/php-parser/pkg/version"
|
2018-02-18 12:25:20 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func BenchmarkPhp7(b *testing.B) {
|
2023-03-25 13:32:14 +00:00
|
|
|
src, err := ioutil.ReadFile(filepath.Join("testdata", "test.php"))
|
2020-12-20 09:38:13 +00:00
|
|
|
if err != nil {
|
2023-03-25 13:32:14 +00:00
|
|
|
b.Fatal("can not read testdata/test.php: " + err.Error())
|
2020-12-20 09:38:13 +00:00
|
|
|
}
|
2018-02-18 12:25:20 +00:00
|
|
|
|
|
|
|
for n := 0; n < b.N; n++ {
|
2021-02-13 21:54:34 +00:00
|
|
|
config := conf.Config{
|
2020-12-29 19:23:22 +00:00
|
|
|
Version: &version.Version{
|
|
|
|
Major: 7,
|
|
|
|
Minor: 4,
|
|
|
|
},
|
|
|
|
}
|
2023-03-25 14:02:34 +00:00
|
|
|
lexer := php7.NewLexer(src, config)
|
2020-12-29 19:23:22 +00:00
|
|
|
php7parser := php7.NewParser(lexer, config)
|
2018-04-10 12:23:13 +00:00
|
|
|
php7parser.Parse()
|
2018-02-18 12:25:20 +00:00
|
|
|
}
|
|
|
|
}
|