Skip to content

Commit

Permalink
Debug log timing information
Browse files Browse the repository at this point in the history
  • Loading branch information
Emily Ekberg committed Apr 20, 2017
1 parent 5c71192 commit 67f7d04
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
5 changes: 5 additions & 0 deletions js/compiler/compiler.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package compiler

import (
"time"

"github.com/GeertJohan/go.rice"
log "github.com/Sirupsen/logrus"
"github.com/dop251/goja"
"github.com/mitchellh/mapstructure"
)
Expand Down Expand Up @@ -53,10 +56,12 @@ func (c *Compiler) Transform(src, filename string) (code string, srcmap SourceMa
}
opts["filename"] = filename

startTime := time.Now()
v, err := c.transform(c.this, c.vm.ToValue(src), c.vm.ToValue(opts))
if err != nil {
return code, srcmap, err
}
log.WithField("t", time.Since(startTime)).Debug("Babel: Transformed")
vO := v.ToObject(c.vm)

if err := c.vm.ExportTo(vO.Get("code"), &code); err != nil {
Expand Down
17 changes: 15 additions & 2 deletions loader/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ import (
"net/http"
"path/filepath"
"regexp"

"strings"
"time"

log "github.com/Sirupsen/logrus"
"github.com/loadimpact/k6/lib"
"github.com/pkg/errors"
"github.com/spf13/afero"
Expand Down Expand Up @@ -139,6 +140,8 @@ func pickLoader(path string) (string, loaderFunc, []string) {
}

func fetch(u string) ([]byte, error) {
log.WithField("url", u).Debug("Fetching source...")
startTime := time.Now()
res, err := http.Get(u)
if err != nil {
return nil, err
Expand All @@ -154,5 +157,15 @@ func fetch(u string) ([]byte, error) {
}
}

return ioutil.ReadAll(res.Body)
data, err := ioutil.ReadAll(res.Body)
if err != nil {
return nil, err
}

log.WithFields(log.Fields{
"url": u,
"t": time.Since(startTime),
"len": len(data),
}).Debug("Fetched!")
return data, nil
}

0 comments on commit 67f7d04

Please sign in to comment.