go-hep.org/x/hep@v0.38.1/fwk/cmd/fwk-cpu-cruncher/loader.go (about) 1 // Copyright ©2017 The go-hep Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package main 6 7 import ( 8 "encoding/json" 9 "os" 10 11 "go-hep.org/x/hep/fwk/job" 12 ) 13 14 func loadConfig(fname string, app *job.Job) { 15 f, err := os.Open(fname) 16 if err != nil { 17 panic(err) 18 } 19 defer f.Close() 20 21 var data struct { 22 Algs []struct { 23 Name string `json:"name"` 24 Inputs []string `json:"inputs"` 25 Outputs []string `json:"outputs"` 26 CPU []int64 `json:"runtimes"` 27 Wall []int64 `json:"runtimes_all"` 28 } `json:"algorithms"` 29 } 30 31 err = json.NewDecoder(f).Decode(&data) 32 if err != nil { 33 panic(err) 34 } 35 36 for _, alg := range data.Algs { 37 app.Create(job.C{ 38 Type: "main.CPUCruncher", 39 Name: alg.Name, 40 Props: job.P{ 41 "Inputs": alg.Inputs, 42 "Outputs": alg.Outputs, 43 "CPU": alg.CPU, 44 }, 45 }) 46 } 47 }