Skip to content

Instantly share code, notes, and snippets.

@jclem
Last active December 19, 2015 15:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jclem/5979042 to your computer and use it in GitHub Desktop.
Save jclem/5979042 to your computer and use it in GitHub Desktop.
package main
import (
"encoding/json"
"io/ioutil"
"os"
)
type Event struct {
Children []Child
EndTime float64
}
type Child struct {
Data ChildData
Type string
}
type ChildData struct {
RequestId string
Url string
StatusCode int
}
func main() {
file := readFile()
getEvents(file)
}
func readFile() []byte {
args := os.Args
file, err := ioutil.ReadFile(args[1])
if err != nil {
panic(err)
}
return file
}
func getEvents(file []byte) []Event {
events := make([]Event, 1)
err := json.Unmarshal(file, &events)
if err != nil {
panic(err)
}
return events
}
$ time ./parse data.json
./parse data.json 4.54s user 0.14s system 99% cpu 4.690 total
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment