github.com/cloud-foundations/dominator@v0.0.0-20221004181915-6e4fee580046/cmd/fsbench/main.go (about)

     1  package main
     2  
     3  import (
     4  	"fmt"
     5  	"os"
     6  
     7  	"github.com/Cloud-Foundations/Dominator/lib/fsbench"
     8  )
     9  
    10  // Benchmark the read speed of the underlying block device for a given file.
    11  func main() {
    12  	pathname := "/"
    13  	if len(os.Args) == 2 {
    14  		pathname = os.Args[1]
    15  	}
    16  	bytesPerSecond, blocksPerSecond, err := fsbench.GetReadSpeed(pathname)
    17  	if err != nil {
    18  		fmt.Fprintf(os.Stderr, "Error! %s\n", err)
    19  		return
    20  	}
    21  	fmt.Printf("speed=%d MiB/s ", bytesPerSecond>>20)
    22  	if blocksPerSecond > 0 {
    23  		fmt.Printf("%d blocks/s\n", blocksPerSecond)
    24  	} else {
    25  		fmt.Println("I/O accounting not available")
    26  	}
    27  }