DumpStats creates the destFile and writes a line per received blob, with its blob size.
(sr *statspkg.Receiver, destFile string)
| 307 | // DumpStats creates the destFile and writes a line per received blob, |
| 308 | // with its blob size. |
| 309 | func DumpStats(sr *statspkg.Receiver, destFile string) { |
| 310 | sr.Lock() |
| 311 | defer sr.Unlock() |
| 312 | |
| 313 | f, err := os.Create(destFile) |
| 314 | if err != nil { |
| 315 | log.Fatal(err) |
| 316 | } |
| 317 | |
| 318 | var sum int64 |
| 319 | for _, size := range sr.Have { |
| 320 | fmt.Fprintf(f, "%d\n", size) |
| 321 | } |
| 322 | fmt.Printf("In-memory blob stats: %d blobs, %d bytes\n", len(sr.Have), sum) |
| 323 | |
| 324 | err = f.Close() |
| 325 | if err != nil { |
| 326 | log.Fatal(err) |
| 327 | } |
| 328 | } |
| 329 | |
| 330 | type stats struct { |
| 331 | files, bytes int64 |