-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
51 lines (40 loc) · 867 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package main
import (
"fmt"
"io/ioutil"
"os"
"time"
_ "yawp/transpiler"
"yawp/parser"
)
//var cpuprofile = flag.String("cpuprofile", "", "write cpu profile to file")
func main() {
var filename string
if len(os.Args) > 1 {
filename = os.Args[1]
} else {
filename = "test/short.js"
}
//opt := &options.Options{
// Target: options.ES2020,
// Minify: true,
//}
src, _ := ioutil.ReadFile(filename)
//f, err := os.Create("main.perf")
//if err != nil {
// log.Fatal(err)
//}
//pprof.StartCPUProfile(f)
//defer pprof.StopCPUProfile()
start := time.Now()
ast, err := parser.ParseModule(filename, src)
if err != nil {
panic(err)
}
ops := time.Now()
//transpiler.Transpile(ast, opt)
fmt.Println("Transpiler pass took: ", time.Since(ops))
fmt.Printf("Parser pass took: %s\n", time.Since(start))
fmt.Println(len(ast.Body))
return
}