weaponx Posted October 25, 2007 Share Posted October 25, 2007 (edited) I would like to thank PSaltyDS for his ProcessListProperties script here:#409276Description:The first part of this script will gather CPU usage for a specified process, at a specified frequency, a specified number of times (if that makes any sense). All of this data gets pumped into a 2 dimensional array.The second part of this script plots the data from the array into a graph. And it's pretty sweet.v1Prime95 (4 cores):In the above picture I loaded up Prime95 but waited about 10 seconds to start the benchmark, you can see it peaks at 100% for the duration.v2Randomly generated data:Actual data from explorer.exe:And here is the code:GraphX.au3GraphXv2.au3 Edited February 15, 2008 by weaponx Link to comment Share on other sites More sharing options...
gcriaco Posted October 26, 2007 Share Posted October 26, 2007 (edited) Congrats. Very nice code. Suggestions: could you show in the graph the RAM usage too (at least the average ram usage counter)? could you write a textual log with ram and cpu usage detected? I mean something like this: timestamp cpu usage ram usage ... ... ... ... ... ... --------------------------------------- Average ram usage: nnn Average cpu usage: nnn Moreover, you could improve the GUI to create a professional process monitoring tool: list of active processes, selection of a process, configuration of the polling time and of the test duration,... Many thanks again for sharing your code and for your help Peppe Edited October 26, 2007 by gcriaco Link to comment Share on other sites More sharing options...
ptrex Posted October 26, 2007 Share Posted October 26, 2007 (edited) @weaponx Realy nice !! regards, ptrex Edited October 26, 2007 by ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
weaponx Posted October 26, 2007 Author Share Posted October 26, 2007 Thanks for checking it out. The next version should be able to plot the data in real time and it will be sweet. Also my GraphX() function is not far off from becoming a full-fledged graph UDF. That way people can insert graphs using native drawing functions instead of embedding Excel OCX.@gcriaco - Your request should be easy. I will put an export button in there somewhere. All of the data is already in an array.I will post more as soon as it's done. Link to comment Share on other sites More sharing options...
weaponx Posted October 31, 2007 Author Share Posted October 31, 2007 (edited) Quick update (v2). -Added a random data function to populate graph.-Added ram usage / average ram usageRandomly generated data:Actual data from explorer.exe:GraphXv2.au3 Edited February 15, 2008 by weaponx Link to comment Share on other sites More sharing options...
Achilles Posted October 31, 2007 Share Posted October 31, 2007 Nice script! The graphs looks great! Could you find a way of telling the user what's happening without making a new TrayTip() every half a second? My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] Link to comment Share on other sites More sharing options...
weaponx Posted October 31, 2007 Author Share Posted October 31, 2007 Nice script! The graphs looks great!Could you find a way of telling the user what's happening without making a new TrayTip() every half a second?Hmm...you could just have one at the end to signal completion. Maybe I can have The Count from Sesame Street read off the remaining time. Link to comment Share on other sites More sharing options...
Zedna Posted October 31, 2007 Share Posted October 31, 2007 Nice script!! Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 2, 2007 Share Posted November 2, 2007 Hmm...you could just have one at the end to signal completion. Maybe I can have The Count from Sesame Street read off the remaining time.Nice script! Looking forward to the Sesame St. skin when you get it done... (green felt?) Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
sg1kritik Posted November 5, 2007 Share Posted November 5, 2007 Wow great work. well done Link to comment Share on other sites More sharing options...
Ibrahim Posted June 28, 2008 Share Posted June 28, 2008 hey man nice code can i ask for a simple code to make a graph just like urs i got lost in arrays and couldn't get it. just simple graph getting their values from text files,Thanks [font="Arial Black"]My Stuff[/font]UPnP Port Forwarding Final.GateWay InformationThe GateWay Watcher(detect speeofing)Rightclick Any file --->Hide/UnhideThe Tip WatcherA PanelShare WatcherThe Arp WatcherThe Online License Checker Link to comment Share on other sites More sharing options...
weaponx Posted July 1, 2008 Author Share Posted July 1, 2008 hey man nice code can i ask for a simple code to make a graph just like urs i got lost in arrays and couldn't get it. just simple graph getting their values from text files,Thanks This is a preview of a udf i'm creating: expandcollapse popup#cs ---------------------------------------------------------------------------- AutoIt Version: 3.2.12.1 Author: WeaponX Script Function: Steam style graph generator #ce ---------------------------------------------------------------------------- #include <GUIConstants.au3> #include <StaticConstants.au3> ;#include <Array.au3> ;Create Main window GUICreate("Graph X", 600, 600, -1) GUISetState (@SW_SHOW) GUISetBkColor (0x424242) ;Left, Top, Width, Height $graph1 = _GraphXCreate(100,30,400,200) ;Left, Top, Width, Height $graph2 = _GraphXCreate(100,300,400,200, 0x000000) ;Generate 60 random integers 0-1000 for 2 seperate lines $randomData = _GraphXRandomData(0, 1000, 60, 2) _GraphXUpdate($graph1,$randomData) _GraphXUpdate($graph2,_GraphXRandomData(50, 100, 20, 4)) Do $msg = GUIGetMsg() Until $msg = $GUI_EVENT_CLOSE ;//////////////////////////////// ;// CREATE GRAPH ;//////////////////////////////// Func _GraphXCreate($graphX, $graphY, $graphWidth = 400, $graphHeight = 100, $graphBGColor = 0x242529, $graphBorderColor = 0x000000, $graphLabelColor = 0x787878) ;Vertical/horizontal gridline interval Local $graphGridXInterval = 8, $graphGridYInterval = 4 ;Define GraphX handle array (this will be returned by this function and used to update the graph) ;[0] = Array containing AutoIt handles to all GUI controls used ;[1-Ubound] = Graph parameters Local $graphHWND[10] =[0, $graphX, $graphY, $graphWidth, $graphHeight, $graphBGColor, $graphBorderColor, $graphLabelColor, $graphGridXInterval, $graphGridYInterval] ;Track ALL GUI controls created by this function so they can be accessed/deleted later ;[0] = Graphic Control (grid) ;[1] = Graphic Control (graph) ;[2-Ubound] = Labels Local $handlesArray[1 + 1 + $graphGridXInterval + 1 + $graphGridYInterval + 1] ;//////////////////////////////// ;// DRAW LABELS ;//////////////////////////////// ;This is used when storing the label handles into the tracking array $lastElement = 1 ;VERTICAL AXIS ;Align vertical axis labels along their left boundary, right justify the text Local $VlabelWidth = 60, $VlabelHeight = 12, $VlabelOffset = 7 ;Label left = Graph left - label width - offset between label and graph $VlabelLeft = $graphX - $VlabelWidth - $VlabelOffset ;Draw a label at every gridline along vertical axis For $X = 0 to $graphGridYInterval $VlabelTop = ((($graphHeight / $graphGridYInterval) * $X) + $graphY) - ($VlabelHeight/2) $lastElement += 1 $handlesArray[$lastElement] = GUICtrlCreateLabel ("", $VlabelLeft, $VlabelTop, $VlabelWidth, $VlabelHeight, $SS_RIGHT) GUICtrlSetColor ($handlesArray[$lastElement], $graphLabelColor) ;GUICtrlSetBkColor ( -1, 0xFFFFFF) ;For debugging GUICtrlSetFont ($handlesArray[$lastElement],8, 600) Next ;HORIZONTAL AXIS ;Align horizontal axis labels along their top boundary, center justify the text Local $HlabelWidth = 30, $HlabelHeight = 12, $HlabelOffset = 4 ;Label top = Graph top + graph height + offset between label and graph $HlabelTop = $graphY + $graphHeight + $HlabelOffset ;Draw a label at every gridline along horizontal axis For $X = 0 to $graphGridXInterval $HlabelLeft = ((($graphWidth / $graphGridXInterval) * $X) + $graphX) - ($HlabelWidth/2) $lastElement += 1 $handlesArray[$lastElement] = GUICtrlCreateLabel ("", $HlabelLeft, $HlabelTop, $HlabelWidth, $HlabelHeight, $SS_CENTER) GUICtrlSetColor ($handlesArray[$lastElement], $graphLabelColor) ;GUICtrlSetBkColor ( -1, 0xFFFFFF) ;For debugging GUICtrlSetFont ($handlesArray[$lastElement],8, 600) Next ;//////////////////////////////// ;// DRAW GRIDLINES ;//////////////////////////////// $graphGrid = GuiCtrlCreateGraphic($graphX, $graphY, $graphWidth,$graphHeight) GUICtrlSetBkColor($graphGrid,$graphBGColor) GUICtrlSetColor ($graphGrid, $graphBorderColor) ;Draw vertical grid lines at specified interval (skip first and last): Y For $X = 1 to $graphGridYInterval - 1 GUICtrlSetGraphic($graphGrid,$GUI_GR_MOVE, 0,$graphHeight * ($X / $graphGridYInterval)) GUICtrlSetGraphic($graphGrid,$GUI_GR_LINE, $graphWidth, $graphHeight * ($X / $graphGridYInterval)) Next ;Draw horizontal grid lines at specified interval (skip first and last): X For $X = 1 to $graphGridXInterval - 1 GUICtrlSetGraphic($graphGrid,$GUI_GR_MOVE, $graphWidth * ($X / $graphGridXInterval),0) GUICtrlSetGraphic($graphGrid,$GUI_GR_LINE, $graphWidth * ($X / $graphGridXInterval), $graphHeight) Next ;Copy pointer to graphic object into custom handle $handlesArray[0] = $graphGrid ;Copy handles sub-array to main array $graphHWND[0] = $handlesArray Return $graphHWND EndFunc ;//////////////////////////////// ;// UPDATE GRAPH ;//////////////////////////////// Func _GraphXUpdate(ByRef $graphHWND, $graphData) ;Extract variables from graph "handle" (maybe a scripting dictionary will replace this, or a 2 dimensional array using variable names in the first dimension + assign) Local $handlesArray = $graphHWND[0] Local $graphX = $graphHWND[1], $graphY = $graphHWND[2] ;X,Y Local $graphWidth = $graphHWND[3], $graphHeight = $graphHWND[4] ;Width, Height Local $graphBGColor = $graphHWND[5], $graphBorderColor = $graphHWND[6], $graphLabelColor = $graphHWND[7] ;Colors Local $graphGridXInterval = $graphHWND[8], $graphGridYInterval = $graphHWND[9] ;Predefined line colors (for up to 5 lines) Local $graphColors[5] = [0xc98d35, 0x686868, 0x880101, 0x0447a2, 0x44672c] ;These need moved...maybe Local $graphMinX = 0, $graphMaxX = Ubound($graphData) Local $graphMinY = 0, $graphMaxY = 0 ;Determine highest Y value from first occurence in the second dimension For $X = 0 to $graphMaxX - 1 If $graphData[$X][0] > $graphMaxY Then $graphMaxY = $graphData[$X][0] Next #cs $graphMinY = $graphMaxY ;Determine lowest Y value from first occurence in the second dimension For $X = 0 to $graphMaxX - 1 If $graphData[$X][0] < $graphMinY Then $graphMinY = $graphData[$X][0] Next #CE ;Delete exisitng graph for redraw GUICtrlDelete ($handlesArray[1]) ;Create the graphic "sandbox" area, this will be drawn on top of the gridline graphic control $graphicSandbox = GuiCtrlCreateGraphic($graphX, $graphY, $graphWidth,$graphHeight) ;//////////////////////////////// ;// UPDATE LABELS ;//////////////////////////////// ;This is used when storing the label handles into the tracking array $lastElement = 1 ;VERTICAL AXIS For $X = 0 to $graphGridYInterval $VLabelValue = $graphMaxY - (($graphMaxY / $graphGridYInterval) * $X) $lastElement += 1 GUICtrlSetData($handlesArray[$lastElement],$VLabelValue) Next ;HORIZONTAL AXIS For $X = 0 to $graphGridXInterval $HLabelValue = ($graphMaxX / $graphGridXInterval) * $X $lastElement += 1 GUICtrlSetData($handlesArray[$lastElement],$HLabelValue) Next ;//////////////////////////////// ;// DRAW LINE GRAPH ;//////////////////////////////// ;Loop through all rows in the array For $X = 0 to $graphMaxX - 1 ;Loop through all occurences in the second dimension For $Y = 0 to Ubound($graphData, 2) - 1 ;Set line thickness ;GUICtrlSetGraphic($graphicSandbox,$GUI_GR_PENSIZE, 1) ;Set line color GUICtrlSetGraphic($graphicSandbox,$GUI_GR_COLOR, $graphColors[$Y]) ;//////////////////////////////// ;// START POINT ;//////////////////////////////// ;At beginning of graph, set X,Y to 0,0 (We use $graphHeight since the Y values are reflected If $X = 0 Then $LastX = 0 $LastY = $graphHeight Else ;Convert input value into proportion that will fit the limits of the graphic control $LastX = ($graphWidth / $graphMaxX) * ($X) ;Reflect Y value $LastY = $graphHeight - (($graphHeight / $graphMaxY) * $graphData[$X-1][$Y]) EndIf ;Truncate Y values that extend beyond the limits of the graph If $LastY > $graphHeight Then $LastY = $graphHeight If $LastY < 0 Then $LastY = 0 ;Truncate X values that extend beyond the limits of the graph If $LastX > $graphWidth Then $LastX = $graphWidth If $LastX < 0 Then $LastX = 0 ;Define starting point GUICtrlSetGraphic($graphicSandbox,$GUI_GR_MOVE, $LastX,$LastY) ;//////////////////////////////// ;// END POINT ;//////////////////////////////// ;Convert input value (relative %) into absolute pixel value $tempX = ($graphWidth / $graphMaxX) * ($X+1) ;Reflect Y value $tempY = $graphHeight - (($graphHeight / $graphMaxY) * $graphData[$X][$Y]) ;Truncate Y values that extend beyond the limits of the graph If $tempY > $graphHeight Then $tempY = $graphHeight If $tempY < 0 Then $tempY = 0 ;Truncate X values that extend beyond the limits of the graph If $tempX > $graphWidth Then $tempX = $graphWidth If $tempX < 0 Then $tempX = 0 GUICtrlSetGraphic($graphicSandbox,$GUI_GR_LINE,$tempX,$tempY) GUICtrlSetGraphic($graphicSandbox,$GUI_GR_REFRESH) ;ConsoleWrite($Y & ": " & @CRLF & "Previous: " & $LastX & "," & $LastY & @CRLF & "Current: " & $tempX & "," & $tempY & @CRLF) Next Next ;Copy pointer to graphic object into custom handle $handlesArray[1] = $graphicSandbox ;Copy handles sub-array to main array $graphHWND[0] = $handlesArray EndFunc ;//////////////////////////////// ;// DESTROY GRAPH ;//////////////////////////////// Func _GraphXRemove(ByRef $graphHWND) Local $handlesArray = $graphHWND[0] For $X = 0 to Ubound($handlesArray) - 1 GUICtrlDelete($handlesArray[$X]) Next EndFunc ;randomMin = Lowest Y value ;randomMax = Highest Y value ;randomResolution = X axis resolution ;randomNumLines = Number of line graphs to generate Func _GraphXRandomData($randomMin, $randomMax, $randomResolution, $randomNumLines = 1) Local $randomArray[$randomResolution][$randomNumLines] For $X = 0 to $randomResolution - 1 For $Y = 0 to $randomNumLines - 1 $randomArray[$X][$Y] = Random($randomMin,$randomMax,1) Next Next Return $randomArray EndFunc Link to comment Share on other sites More sharing options...
Ibrahim Posted July 1, 2008 Share Posted July 1, 2008 Thanks man gonna give it a try [font="Arial Black"]My Stuff[/font]UPnP Port Forwarding Final.GateWay InformationThe GateWay Watcher(detect speeofing)Rightclick Any file --->Hide/UnhideThe Tip WatcherA PanelShare WatcherThe Arp WatcherThe Online License Checker Link to comment Share on other sites More sharing options...
trademaid Posted October 12, 2009 Share Posted October 12, 2009 (edited) can someone tell me how to measure cpu of just one process? ie explorer.exe i want to do if cpu of explorere.exe >90 then soundplay(..... Edited October 12, 2009 by trademaid Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now