| 135 | } |
| 136 | |
| 137 | func testQuery(entity []string, name string, q1 string, q2 string) { |
| 138 | rm := Query(entity, q1, q2) |
| 139 | file, err := os.Create(name + ".csv") |
| 140 | checkErr(err, "Error while opening file") |
| 141 | defer file.Close() |
| 142 | |
| 143 | w := csv.NewWriter(file) |
| 144 | |
| 145 | for k, v := range rm { |
| 146 | numEntities := strconv.Itoa(k) |
| 147 | avgRatio := strconv.FormatFloat(v.ratio/float64(v.count), 'E', -1, 64) |
| 148 | jsonL := strconv.FormatInt(v.jsonL/int64(v.count), 10) |
| 149 | if err := w.Write([]string{numEntities, avgRatio, jsonL}); err != nil { |
| 150 | glog.WithField("err", err).Fatal("error writing record to csv") |
| 151 | } |
| 152 | } |
| 153 | w.Flush() |
| 154 | if err := w.Error(); err != nil { |
| 155 | log.Fatal(err) |
| 156 | } |
| 157 | } |
| 158 | |
| 159 | func main() { |
| 160 | flag.Parse() |