2018-02-18 12:25:20 +00:00
|
|
|
package php7_test
|
|
|
|
|
|
|
|
import (
|
2020-12-20 09:38:13 +00:00
|
|
|
"io/ioutil"
|
2018-02-18 12:25:20 +00:00
|
|
|
"testing"
|
|
|
|
|
2020-05-12 21:16:36 +00:00
|
|
|
"github.com/z7zmey/php-parser/internal/php7"
|
2020-06-29 20:00:56 +00:00
|
|
|
"github.com/z7zmey/php-parser/internal/scanner"
|
2020-12-29 19:23:22 +00:00
|
|
|
"github.com/z7zmey/php-parser/pkg/cfg"
|
|
|
|
"github.com/z7zmey/php-parser/pkg/version"
|
2018-02-18 12:25:20 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func BenchmarkPhp7(b *testing.B) {
|
2020-12-20 09:38:13 +00:00
|
|
|
src, err := ioutil.ReadFile("test.php")
|
2018-02-18 12:25:20 +00:00
|
|
|
|
2020-12-20 09:38:13 +00:00
|
|
|
if err != nil {
|
|
|
|
b.Fatal("can not read test.php: " + err.Error())
|
|
|
|
}
|
2018-02-18 12:25:20 +00:00
|
|
|
|
|
|
|
for n := 0; n < b.N; n++ {
|
2020-12-29 19:23:22 +00:00
|
|
|
config := cfg.Config{
|
|
|
|
Version: &version.Version{
|
|
|
|
Major: 7,
|
|
|
|
Minor: 4,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
lexer := scanner.NewLexer(src, config)
|
|
|
|
php7parser := php7.NewParser(lexer, config)
|
2018-04-10 12:23:13 +00:00
|
|
|
php7parser.Parse()
|
2018-02-18 12:25:20 +00:00
|
|
|
}
|
|
|
|
}
|