I'm currently working on piece of work that runs image manipulation both sequentially and in parallel. I'm trying to work out the work rate as part of my Metrics however I can't find a formula online or much information about it,
Does anyone have the equation required to calculate work rate?
Edit:
This is my main function which has the metric calculations in if this helps? I know there are probably better ways for me to obtain certain data etc, but a bit of trial and error has got me to this point.
runtime.GOMAXPROCS(4)
file, err := os.Open("space.jpg")
if err != nil {
log.Fatal(err)
}
defer file.Close()
img, err := jpeg.Decode(file)
if err != nil {
log.Fatal(os.Stderr, "%s: %v
", "space.jpg", err)
}
for i:= 0; i<10; i++{
TSeqStart := time.Now()
b := img.Bounds()
imgSet := image.NewRGBA(b)
for y := 0; y < b.Max.Y; y++ {
for x := 0; x < b.Max.X; x++ {
oldPixel := img.At(x, y)
r, g, b, _ := oldPixel.RGBA()
lum := 0.299*float64(r) + 0.587*float64(g) + 0.114*float64(b)
pixel := color.Gray{uint8(lum / 256)}
imgSet.Set(x, y, pixel)
}
}
TSeq := time.Since(TSeqStart)
//ns := TSeq.Nanoseconds()
avgSeq = avgSeq +TSeq
fmt.Printf("
Time in ns (Sequential): " , TSeq)
outFile, err := os.Create("changed.jpg")
if err != nil {
log.Fatal(err)
}
defer outFile.Close()
jpeg.Encode(outFile, imgSet, nil)
}
avgSeq = avgSeq/10
fmt.Print("
Average sequential time for 10 runs: ", avgSeq)
//parallel version
file2, err := os.Open("space.jpg")
if err != nil {
log.Fatal(err)
}
defer file.Close()
img2, err := jpeg.Decode(file2)
if err != nil {
log.Fatal(os.Stderr, "%s: %v
", "space.jpg", err)
}
for j:=1;j<=4;j++{
runtime.GOMAXPROCS(j)
for i:= 0; i<10; i++{
TParStart:= time.Now()
imgSet2 := imgprocess(img2, runtime.NumCPU(), splitVert(1024), rgbtogrey)
TPar := time.Since(TParStart)
//ns2 := TPar.Nanoseconds()
avgPar = avgPar +TPar
fmt.Print("
Time in Nanoseconds (Parallel) with GOMAXPROCS set at ",j ,": " , TPar)
outFile2, err := os.Create("changed2.jpg")
if err != nil {
log.Fatal(err)
}
defer outFile2.Close()
jpeg.Encode(outFile2, imgSet2, nil)
if err != nil {
log.Fatalf("encoding image: %v", err)
}
}
avgPar = avgPar/10
fmt.Print("
Average time for 10 runs in parallel (GOMAXPROCS:",j,"): ", avgPar)
var j64 time.Duration
j64 = time.Duration(j)
totalPar := j64*avgPar
fmt.Print("
Total Parallel time: ", totalPar)
speedup := avgSeq.Seconds()/avgPar.Seconds()
fmt.Printf("
Speed up: %f", speedup)
var jfloat float64
jfloat = float64(j)
theoreticalMin := avgSeq.Seconds()/jfloat
fmt.Print("
Theoretical Minimum: ", theoreticalMin,"ms")
var tPFloat float64
tPFloat = float64(totalPar)
efficiency := avgSeq.Seconds()/tPFloat
fmt.Print("
Efficiency: ", efficiency,"%")
overhead := totalPar - avgSeq
fmt.Print("
Overhead time: ", overhead ,"
")