Skip to content

Commit

Permalink
flush write to file call
Browse files Browse the repository at this point in the history
  • Loading branch information
sukunrt committed Sep 17, 2021
1 parent 68cfc6d commit 9b337b7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.out
6 changes: 4 additions & 2 deletions disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ func writeData(s string, inp []byte) {
}
}()
f.Write([]byte(inp))
f.Sync()
}

func makeData(n int) []byte {
Expand All @@ -35,10 +36,11 @@ func readData(s string, n int) (int, []byte) {

func main() {
mx := 1000000000
inp := makeData(mx)
st := time.Now()
x, _ := readData("output.txt", mx)
writeData("output.txt", inp)
d := time.Since(st)
fmt.Println("time taken ", d, x)
fmt.Println("time taken ", d)
tp := float64(mx) / d.Seconds()
fmt.Printf("through put is %2f MB/s", tp/(MB))
}

0 comments on commit 9b337b7

Please sign in to comment.