[refactoring] update makefile

This commit is contained in:
Vadym Slizov 2020-05-18 22:36:39 +03:00
parent a636a14faa
commit 21f3d88b0f
2 changed files with 18 additions and 15 deletions

View File

@ -19,8 +19,8 @@ cover:
go test ./... --cover
bench:
go test -benchmem -bench=. ./php5
go test -benchmem -bench=. ./php7
go test -benchmem -bench=. ./internal/php5
go test -benchmem -bench=. ./internal/php7
compile: ./internal/php5/php5.go ./internal/php7/php7.go ./internal/scanner/scanner.go fmt
sed -i '' -e 's/yyErrorVerbose = false/yyErrorVerbose = true/g' ./internal/php7/php7.go
@ -40,17 +40,17 @@ compile: ./internal/php5/php5.go ./internal/php7/php7.go ./internal/scanner/scan
goyacc -o $@ $<
cpu_pprof:
go test -cpuprofile cpu.pprof -bench=. -benchtime=20s ./php7
go test -cpuprofile cpu.pprof -bench=. -benchtime=20s ./internal/php7
go tool pprof ./php7.test cpu.pprof
mem_pprof:
go test -memprofile mem.pprof -bench=. -benchtime=20s -benchmem ./php7
go test -memprofile mem.pprof -bench=. -benchtime=20s -benchmem ./internal/php7
go tool pprof -alloc_objects ./php7.test mem.pprof
cpu_pprof_php5:
go test -cpuprofile cpu.prof -bench=. -benchtime=20s ./php5
go test -cpuprofile cpu.prof -bench=. -benchtime=20s ./internal/php5
go tool pprof ./php5.test cpu.prof
mem_pprof_php5:
go test -memprofile mem.prof -bench=. -benchtime=20s -benchmem ./php5
go test -memprofile mem.prof -bench=. -benchtime=20s -benchmem ./internal/php5
go tool pprof -alloc_objects ./php5.test mem.prof

View File

@ -1,9 +1,9 @@
package main
import (
"bytes"
"flag"
"fmt"
"github.com/z7zmey/php-parser/pkg/ast/traverser"
"io/ioutil"
"log"
"os"
@ -13,8 +13,11 @@ import (
"github.com/pkg/profile"
"github.com/yookoala/realpath"
"github.com/z7zmey/php-parser/pkg/ast/traverser"
"github.com/z7zmey/php-parser/pkg/ast/visitor"
"github.com/z7zmey/php-parser/pkg/parser"
"github.com/z7zmey/php-parser/pkg/printer"
)
var wg sync.WaitGroup
@ -138,14 +141,14 @@ func printerWorker(r <-chan result) {
fmt.Fprintf(os.Stdout, "==> %s\n", e)
}
//if *printBack {
// o := bytes.NewBuffer([]byte{})
// p := printer.NewPrinter(o)
// p.Print(res.parser.GetRootNode())
//
// err := ioutil.WriteFile(res.path, o.Bytes(), 0644)
// checkErr(err)
//}
if *printBack {
o := bytes.NewBuffer([]byte{})
p := printer.NewPrinter(o)
p.Print(res.parser.GetRootNode())
err := ioutil.WriteFile(res.path, o.Bytes(), 0644)
checkErr(err)
}
if *showResolvedNs {
v := visitor.NewNamespaceResolver()