Loading ...
Sorry, an error occurred while loading the content.

Re: [perlguitest] How to check memory usage in Windows with Perl?

Expand Messages
  • Martin McGrath
    Please post only Win32::GuiTest questions to this list, not general Perl questions. Wallace Lai wrote:
    Message 1 of 6 , Oct 5, 2006
    • 0 Attachment
      Please post only Win32::GuiTest questions to this list, not general Perl questions.

      Wallace Lai <wallace_g_lai@...> wrote: Hi, All,

      Can I use Perl to check the amount of memory used by
      certain app, like NotePad and Internet Explorer? And
      can I use Perl to check the amount of free memory?

      I am using it on Microsoft Windows.

      Thanks
      Wallace Lai

      __________________________________________________
      Do You Yahoo!?
      Tired of spam? Yahoo! Mail has the best spam protection around
      http://mail.yahoo.com






      ---------------------------------
      Now you can scan emails quickly with a reading pane. Get the new Yahoo! Mail.

      [Non-text portions of this message have been removed]
    • stuart arnold
      check out ScriptomaticV2.hta from microsoft. its free and does a lot of object manipulation per object in perl, and other languages. modifiable as well.
      Message 2 of 6 , Oct 12, 2006
      • 0 Attachment
        check out "ScriptomaticV2.hta" from microsoft. its free and does a lot of
        object manipulation "per object" in perl, and other languages. modifiable as
        well.

        -----Original Message-----
        From: perlguitest@yahoogroups.com [mailto:perlguitest@yahoogroups.com] On
        Behalf Of kapil sharma
        Sent: Friday, October 06, 2006 1:13 AM
        To: perlguitest@yahoogroups.com
        Subject: Re: [perlguitest] How to check memory usage in Windows with Perl?



        Hi,
        I hope this helps.

        Regards,
        Kapil

        #The following API checks the following
        #CPU Time which is equal to KETNEL MODE + USER MODE
        TIME
        #PEAK MEMORY

        For details check www.perlmonks.com

        sub DumpPerformanceData
        {
        $OsName = Win_OS_Type();

        $ExeNameInTaskManager = "Your Executable Name goes
        here"; #If you have Win2000

        if ( lc($OsName) eq lc("XP") )
        {
        $ExeNameInTaskManager = "Your Executable Name goes
        here"; #If you have WinXP
        }

        foreach my $Proc ( sort {lc $a->{Name} cmp lc
        $b->{Name}} in( $WMI->InstancesOf( "Win32_Process" ) )
        )
        {
        $numberofProcesses++;
        $|=1;
        $TempProcessID =0;
        $TempProcessID = $Proc->{ProcessID};
        $KernelModeTime = 0;
        $UserModeTime = 0;

        if (lc($Proc->{Name}) eq lc($ExeNameInTaskManager))
        #Checking if the PID of the Process = PID of the your
        exe
        {
        $PID = $Proc->{ProcessID};

        $KernelModeTime = $Proc->{KernelModeTime};
        $UserModeTime = $Proc->{UserModeTime};
        $PeakMemoryUsage = ($Proc->{PeakWorkingSetSize}) /
        1024;

        $TotalCPUTime = $UserModeTime + $KernelModeTime;
        $TotalCPUTime = $TotalCPUTime / 10000000;

        #Defining and opening the main log file
        if($ARGV[3] == 1)
        {
        $PerformanceLogFile =
        $ARGV[1]."\\"."Performancedata.log";
        }
        else
        {
        $PerformanceLogFile =
        $ARGV[1]."\\"."Performancedata_new.log";
        }

        open PerformanceLogFileHandle,
        ">>$PerformanceLogFile" or warn "Can't open the log
        file in automation: $PerformanceLogFile : $!\n";

        print PerformanceLogFileHandle "$ARGV[0]\n";
        print PerformanceLogFileHandle "Total CPU Time =
        $TotalCPUTime\n";
        print PerformanceLogFileHandle "PeakMemoryUsage =
        $PeakMemoryUsage\n";
        close(PerformanceLogFileHandle);
        return 1;
        }

        } #End of "foreach my $Proc ( sort {lc $a->{Name} cmp
        lc $b->{Name}} in( $WMI->InstancesOf( "Win32_Process"
        ) ) )"

        }

        ###################################

        --- Wallace Lai <wallace_g_lai@ <mailto:wallace_g_lai%40yahoo.com>
        yahoo.com> wrote:

        > Hi, All,
        >
        > Can I use Perl to check the amount of memory used by
        > certain app, like NotePad and Internet Explorer?
        > And
        > can I use Perl to check the amount of free memory?
        >
        > I am using it on Microsoft Windows.
        >
        > Thanks
        > Wallace Lai
        >
        > __________________________________________________
        > Do You Yahoo!?
        > Tired of spam? Yahoo! Mail has the best spam
        > protection around
        > http://mail. <http://mail.yahoo.com> yahoo.com
        >
        >
        >
        >

        The information in this message is confidential and may be legally
        privileged. It is intended solely for the addressee. Access to this message
        by anyone else is unauthorized. If you are not the intended recipient, any
        disclosure, copying, or distribution of the message, or any action or
        omission taken by you in reliance on it, is prohibited and may be unlawful.
        Please immediately contact the sender if you have received this message in
        error.

        __________________________________________________
        Do You Yahoo!?
        Tired of spam? Yahoo! Mail has the best spam protection around
        http://mail. <http://mail.yahoo.com> yahoo.com







        [Non-text portions of this message have been removed]
      Your message has been successfully submitted and would be delivered to recipients shortly.