-
-
Save kchester12/d0f31b66fe7115da65fdf342b6cb42e8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"flag" | |
"fmt" | |
"github.com/chrislusf/glow/flow" | |
"github.com/dgruber/ugego/pkg/accounting" | |
"os" | |
"strings" | |
) | |
func main() { | |
flag.Parse() | |
accountingFileName := fmt.Sprintf("%s/%s/common/accounting", os.Getenv("SGE_ROOT"), os.Getenv("SGE_CELL")) | |
flow.New().TextFile( | |
accountingFileName, 4, | |
).Filter(func(line string) bool { | |
return !strings.HasPrefix(line, "#") | |
}).Map(func(line string, ch chan accounting.Entry) { | |
if e, err := accounting.ParseLine([]byte(line)); err == nil { | |
ch <- e | |
} | |
}).Reduce(func(x accounting.Entry, y accounting.Entry) accounting.Entry { | |
y.CPU += x.CPU | |
return y | |
}).Map(func(out accounting.Entry) { | |
fmt.Println("Combined CPU times of all jobs.") | |
fmt.Printf("%f\n", out.CPU) | |
}).Run() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment