Revision 73ea5effe5e8ad6dfaf4a3923830d89a35274663 authored by Kunal Dhariwal on 15 January 2019, 13:12:35 UTC, committed by Anton Kaliaev on 15 January 2019, 13:12:35 UTC
1 parent 4daca1a
os_test.go
package benchmarks
import (
"os"
"testing"
cmn "github.com/tendermint/tendermint/libs/common"
)
func BenchmarkFileWrite(b *testing.B) {
b.StopTimer()
file, err := os.OpenFile("benchmark_file_write.out",
os.O_RDWR|os.O_CREATE|os.O_APPEND, 0600)
if err != nil {
b.Error(err)
}
testString := cmn.RandStr(200) + "\n"
b.StartTimer()
for i := 0; i < b.N; i++ {
_, err := file.Write([]byte(testString))
if err != nil {
b.Error(err)
}
}
if err := file.Close(); err != nil {
b.Error(err)
}
if err := os.Remove("benchmark_file_write.out"); err != nil {
b.Error(err)
}
}
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...