Skip to content

Instantly share code, notes, and snippets.

@nemo-kaz
Created November 23, 2010 07:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nemo-kaz/711401 to your computer and use it in GitHub Desktop.
Save nemo-kaz/711401 to your computer and use it in GitHub Desktop.
Top command for Windows
// Top command:
// Windows依存です、CPU負荷の高い順に10プロセス表示します
def command = "cmd /c tasklist.exe /v> output.txt"
command.execute()
List rated=[]
List cputime=[]
new File("output.txt").eachLine{line ->
cputime=line.split(' +')
rated.add(cputime)
}
rated = rated.sort{ a,b -> a[5] <=> b[5] }.reverse()
rated[0..9].each {item ->
print item[0]+"\t"
print item[5]
println ""
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment